1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-17 23:23:43 +02:00
Commit Graph

550 Commits

Author SHA1 Message Date
gendx
710fd526b4
Clarification in Trait Objects. (#379) 2023-02-09 21:51:08 +00:00
gendx
91eec89c52
Clarify that trait bounds give access to methods and add example of impl Trait. (#378) 2023-02-09 21:50:34 +00:00
gendx
f912825411
Add documentation links to the important traits. (#377)
* Add documentation links to the important traits.

* Also add links in the sub-pages.
2023-02-09 21:47:47 +00:00
gendx
fbb12161eb
Mention rc::Weak and add an example with a cycle in the speaker notes. (#375) 2023-02-09 21:46:40 +00:00
gendx
f9f04651ce
Add more example methods to Vec and HashMap. (#373) 2023-02-09 21:45:43 +00:00
Charisee Chiw
3a734230c9
Update visibility.md (#357) 2023-02-09 21:19:56 +00:00
Charisee Chiw
cf931075d5
Update destructuring-arrays.md (#369)
* Update destructuring-arrays.md

* Update destructuring-arrays.md
2023-02-09 13:17:33 -08:00
Charisee Chiw
6a1282c166
Update for-expressions.md (#359)
* Update for-expressions.md

* Update for-expressions.md

* Update for-expressions.md

* Fix formatting.

---------

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-02-09 21:17:15 +00:00
Charisee Chiw
65340c4ca1
Update match-expressions.md (#367)
* Update match-expressions.md

* Apply suggestions from code review

Fine tuning the casing and explanations.

---------

Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-02-09 13:16:30 -08:00
Marko Zagar
36ce63cb10
Updates and minor fixes to Day 2: Morning (#372) 2023-02-09 21:15:47 +00:00
Charisee Chiw
e3b4b6a5c7
Update box.md (#363) 2023-02-09 20:55:19 +00:00
Charisee Chiw
736de71c7c
Update loop-expressions.md (#362)
* Update loop-expressions.md

* Update loop-expressions.md

* Fix formatting.

---------

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-02-09 20:52:37 +00:00
Charisee Chiw
1587d796cb
Update modules.md (#358)
* Update modules.md

* Update modules.md

* Fix capitalisation and formatting.

---------

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-02-09 20:50:43 +00:00
Charisee Chiw
426d7d91c2
Update points-polygons.md (#361) 2023-02-09 20:49:35 +00:00
Charisee Chiw
aa316544c3
Update box-recursive.md (#360) 2023-02-09 20:49:00 +00:00
Martin Geisler
c4bc10e31d
Inline variables printed with println! and friends (#315)
The course follows the style of inlining variable names where possible
in `println!` statements.
2023-02-09 07:48:18 +01:00
gendx
ce19841249
Add highly-unsafe speaker notes to inspect the memory layout of string. (#341) 2023-02-09 07:47:15 +01:00
Charisee Chiw
1835896e58
Speaker notes for destructuring-structs.md (#265)
* Update destructuring-structs.md

* Update destructuring-structs.md
2023-02-07 07:42:57 +00:00
Igor Petruk
ab831de1da
Suggesting to add Default to important traits. (#243)
* Suggesting to add `Default` to important traits.

This is a great trait to know about, it is used very often.

* Change `Implemented` to tuple struct.

It saves vertical space.
2023-02-06 20:17:21 +01:00
karthicktamil
fd82a95e85
Update welcome-day-1.md (#350)
Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-02-06 18:47:53 +00:00
gendx
0be6f639bd
Add a totally-unsafe example to show the discriminant optimization of Options. (#345) 2023-02-06 17:41:54 +01:00
gendx
c3e3dc6020
Add speaker notes for pattern-matching/destructuring-arrays.md (#346) 2023-02-06 17:38:01 +01:00
Becker A
6361b2ed63
Update welcome-day-1.md (#349)
fix grammar typo
2023-02-06 07:34:55 +00:00
gendx
2e076cabe7
Reference mdbook installation instructions from running-the-course.md. (#329) 2023-02-03 15:52:06 +00:00
gendx
cc4509f90c
Add historical reference to the Rust 1.0 release. (#335) 2023-02-03 15:51:41 +00:00
gendx
bd98d03b44
Remove dangling links in cargo/rust-ecosystem.md. (#332) 2023-02-03 15:50:15 +00:00
gendx
ace97aaeb2
Fix typo in basic-syntax/variables.md. (#339) 2023-02-03 15:30:44 +00:00
gendx
b5518e9b16
Add a solution for day 1's bonus question with generics. (#338) 2023-02-03 15:29:49 +00:00
gendx
1936cd5c85
Mention that the syntax is similar to Java as well. (#337) 2023-02-03 15:28:38 +00:00
gendx
22d2bd36e4
Add reference to rustfmt for Debian instructions. (#331) 2023-02-03 15:18:03 +00:00
Andrew Gaul
f33b1f923a
Use f-string in example for consistency (#328)
Also fix typo.
2023-02-03 13:07:29 +00:00
Andrew Walbran
1be641203e
Split out example to separate page. (#319)
The example is quite long and so the page didn't easily fit on the
same screen as the explanation
2023-02-03 10:12:31 +00:00
Andrew Walbran
20f02db5f5
Add a cargo workspace containing both crates (#321)
* Move Cargo.toml for exercises to exercises directory.

* Create a workspace with both exercises and i18n-helpers.

* Build in CI as well as testing.

* Binaries must have a main function.

* No need for workspaces configuration for caching anymore.
2023-02-02 16:14:34 +00:00
Martin Geisler
a07bfa108f
Wrap long line of code (#312)
This line was too big to show during class.
2023-02-01 12:34:10 +01:00
Martin Geisler
476ee283c6
Simplify Vec slide (#313)
The code is probably meant to illustrate the `vec!` macro, but it
feels out of place when teaching: there is already enough material
here to get through.
2023-02-01 10:49:11 +01:00
Martin Geisler
d6182ea498
Fix missing word (#311) 2023-01-31 20:09:00 +00:00
Martin Geisler
c6a54ce9a9
Show the pair returned by duplicate (#314)
This makes it easier to talk about the code as you make changes to the
`duplicate` function.
2023-01-31 21:08:09 +01:00
Martin Geisler
dee5e654c8
Fix order of standard library slides (#310)
The slides now follow the order on the intro slide.
2023-01-31 15:04:17 -05:00
Frieder Bluemle
fd65ff0f0c
Fix JetBrains capitalization (#305)
* Fix JetBrains capitalization

* Revert change to da.po

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-31 19:45:54 +00:00
lodisy
330d21ef02 Update traits.md 2023-01-31 11:07:24 +00:00
Igor Petruk
100ee591ed
Update unsafe.md (#252)
* Update unsafe.md

Adding a paragraph explaining that unsafe code is not necessary broken or evil, but it is a mode
where compiler safety features are off.

* Move explanation to speaker notes

To avoid slide being too long. Also edited text slightly.

* Remove extra space

---------

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-30 13:12:51 +00:00
Charisee Chiw
601dc8258b
Speaker notes for vec.md (#296)
* Speaker notes for vec.md

* Fix grammar and formatting

* Fix formatting and spelling.

---------

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-30 11:56:30 +00:00
Charisee Chiw
49d24f89cf
Speaker notes for while-let-expressions.md (#294)
* Speaker notes for while-let-expressions.md

#274

* Update while-let-expressions.md

---------

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-30 11:47:56 +00:00
CodeMaster7000
31ae4ac56b
Rename LICENSE.txt to LICENSE (#293)
* Rename LICENSE.txt to LICENSE

* Update credits.md
2023-01-29 14:20:55 +01:00
focksor surooi
43c5344785
Fix typos (#297)
* fix typo in running-the-course.md

* Update modern.md
2023-01-29 11:54:51 +00:00
Mao Yufeng
49e06ffe03
Fix link to solution on Day 3 exercise (#299)
* fix day-3 solutions link

* Fix link description by making it singular

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-29 12:52:32 +01:00
Andrew Walbran
27b6165202 Implement Error. 2023-01-27 17:54:37 +00:00
Andrew Walbran
caaca140ca Another note for anyhow. 2023-01-27 17:54:37 +00:00
Andrew Walbran
79f5f0dade Add slide about Box<dyn Error> before introducing anyhow. 2023-01-27 17:54:37 +00:00
Andrew Walbran
e5c97e12cb No need for thiserror as well as anyhow. 2023-01-27 17:54:37 +00:00
Andrew Walbran
9fa0e89e90 It makes no sense to use both return and ?. 2023-01-27 17:54:37 +00:00
Andrew Walbran
52d28b155b Mention std::error::Error in speaker notes, and other useful traits. 2023-01-27 17:54:37 +00:00
Andrew Walbran
5dd87192e8 Mention that Send and Sync are unsafe traits. 2023-01-27 17:34:31 +00:00
Andrew Walbran
81cf02ffbe Fix typos and details. 2023-01-27 17:34:31 +00:00
Andrew Walbran
cc402a7788 Add some speaker notes to concurrency chapter. 2023-01-27 17:34:31 +00:00
Andrew Walbran
c066ab5664 Mention other ABI options. 2023-01-27 17:17:37 +00:00
Andrew Walbran
95c0447e4b Remove comment inside unsafe block.
Martin thinks the safety comment at the top is enough.
2023-01-27 17:17:37 +00:00
Andrew Walbran
facbac4601 Fix typo, and this is not specific to glibc. 2023-01-27 17:17:37 +00:00
Andrew Walbran
6e7916c29b Add a slide about writing unsafe functions. 2023-01-27 17:17:37 +00:00
Andrew Walbran
3cadad4e0a Add slide for unsafe traits. 2023-01-27 17:17:37 +00:00
Andrew Walbran
8c2b3781bb Move extern functions slide under unsafe functions. 2023-01-27 17:17:37 +00:00
Andrew Walbran
7deb5532ea Add speaker notes for extern functions. 2023-01-27 17:17:37 +00:00
Andrew Walbran
d07171e76d Add safety comment. 2023-01-27 17:17:37 +00:00
Andrew Walbran
47e28e87c0 Add speaker notes for unions. 2023-01-27 17:17:37 +00:00
Andrew Walbran
d7fcf8216a Mutable statics are generally a bad idea. 2023-01-27 17:17:37 +00:00
Andrew Walbran
9bed4fce3c Add speaker notes and safety comment for raw pointers. 2023-01-27 17:17:37 +00:00
Andrew Walbran
062905e7d7 There's no name involved here. 2023-01-27 17:17:37 +00:00
Andrew Walbran
e0cb292624 Put unsafe slides in same order as they are introduced in unsafe.md. 2023-01-27 17:17:37 +00:00
Charisee Chiw
1453e1d5bb Update blocks.md 2023-01-27 12:03:49 +00:00
Igor Petruk
585509bb0a
Update points-polygons.md (#234)
Adding speaker notes with key things that might be present in the solution.
2023-01-26 19:04:03 +01:00
Charisee Chiw
4588d95427 Update match-guards.md 2023-01-26 12:08:21 +00:00
Davide Guerri
a0a1059c0d Verbose description of Sync-Send relationship
Add a verbose rationale of the statement:
  `T` is `Sync` if and only if `&T` is `Send`
2023-01-26 12:06:54 +00:00
Alexei Ermakov
f0310f4f61 Fixed link to IntoIterator for Vec doc 2023-01-26 12:04:58 +00:00
rbehjati
f15fc1a0b8
Add discussion points for traits (#180)
* Some discussion points for traits
* Add answers
2023-01-26 09:14:05 +00:00
upsidedwn
ec01563bd6
Propose to use the generic term perimeter instead of circumference for shapes (#281)
* Update unit tests to use generic perimeter

* Update solution to use perimeter

Update solution to use the generic term perimeter instead of circumference
2023-01-26 08:59:13 +00:00
Charisee Chiw
f3446a9176
Speaker notes for methods.md (#202)
* Update methods.md

* Update methods.md

* Update methods.md

* Reword explanation of methods

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-24 10:46:13 -08:00
Igor Petruk
da666548a7
Update example.md (#230)
Adding the line that you can no longer call `add_lap` after the race is finished.
2023-01-24 15:27:29 +01:00
Igor Petruk
b12a1cb320
Update example.md (#257)
Adding a possible solution to the example that
does not compile. The solution includes notes
with important parts.
2023-01-24 15:25:18 +01:00
Marko Zagar
10ca7b1b2d
More fixes and additions to Day1 Morning (#269)
* Corrections around slices and string slices, also slight improvements to the language.

* Explained some of the confusing details in the functions example.

* Added a speaker note (hinting at `Into`  as a complement to generics).

* Exclude the clarification code snippet from build testing.

* Update functions-interlude.md

Do not mention explicit section numbers as they may change.
2023-01-24 15:20:18 +01:00
Andrew Walbran
b064642b02 Make program consistent with output given. 2023-01-24 11:45:04 +00:00
Andrew Walbran
536c1dc90b Speaker notes for Android chapter. 2023-01-24 11:45:04 +00:00
Igor Petruk
6702accbbb
Update string-slices.md (#209)
* Update string-slices.md

* Adding an extra example of converting `String` back to `&str`.
* C++ who would often read this guide could get immediate intuitive understanding of Rust strings if you compare them to C++ equivalents.

* Expand on `String` vs `std::string`

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-24 08:52:55 +00:00
Igor Petruk
4444e9a078
Update lifetimes-function-calls.md (#223)
* Update lifetimes-function-calls.md

I am trying to describe the problem lifetimes solve. It may seem they are complex and useless, but the paragraph starts from the problem Rust cannot
solve on it's own (yet). Then the paragraph illustrates the problem represented in the code and how lifetimes solve it.

* Update lifetimes-function-calls.md

Moving the generic explanation of why lifetimes are important to the speaker notes.

* Make language more direct

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-24 09:50:05 +01:00
Igor Petruk
7f178d6212
Update mutex.md (#256)
* Update mutex.md

Adding speaker notes why Rust `Mutex` has its design and mentioning briefly `RwLock`.

Someone from the audience can notice `unwrap()` in the code, it might be worth to have the answer in speaker notes.

* Apply suggestions from code review

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-24 08:43:27 +00:00
Igor Petruk
178d7104e6
Update channels.md (#254)
* Update channels.md

Adding speaker notes explaining why `send` and `recv` can fail.

* Explicitly mention that the channel is closed when the sender/receiver is dropped

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-24 08:35:48 +00:00
Igor Petruk
617f4e2bb7
Update error-contexts.md (#251)
* Update error-contexts.md

Adding more speaker notes about `anyhow`.

* Add markup

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-24 07:33:03 +00:00
Igor Petruk
912f592199
Update copy-clone.md (#221) 2023-01-23 21:26:21 +01:00
Igor Petruk
fe8fa8d232
Update Speaker Notes for slices.md (#208)
It makes sense to add a speaker note about the question asked.
2023-01-23 21:23:41 +01:00
Charisee Chiw
a517ff5816
Speaker notes for pattern matching (#260)
* Speaker notes for pattern matching

* Update pattern-matching.md

Co-authored-by: Fabian Bornhofen <fbornhofen@google.com>
2023-01-23 21:22:01 +01:00
Charisee Chiw
bd3642694b
Update destructuring-enums.md (#261)
* Update destructuring-enums.md

* Update destructuring-enums.md

Following the typesetting and terminology used in https://doc.rust-lang.org/book/ch03-05-control-flow.html and https://doc.rust-lang.org/book/ch06-02-match.html

Co-authored-by: Fabian Bornhofen <fbornhofen@google.com>
2023-01-23 21:20:08 +01:00
Fabian Bornhofen
55fbb23cca
Add speaker notes for trait objects (#194) 2023-01-23 21:11:53 +01:00
Charisee Chiw
5792806947
Update structs.md (#195)
* Update structs.md

* Update structs.md

* Update structs.md

* Update structs.md
2023-01-23 10:07:29 -08:00
Igor Petruk
1c36b5d771
Update if-let-expressions.md (#237)
Mention `let else` in the speaker notes.
2023-01-23 10:05:06 -08:00
Igor Petruk
30291800ec
Update vec.md (#240)
Adding Speaker Notes about type inference in collections and `vec![]` macro.
2023-01-23 10:04:52 -08:00
Igor Petruk
49c9ba692e
Update static-and-const.md (#215)
Let's not use the word "lifetime" just yet. It is arguably the heaviest topic in Rust and it was not yet introduced.
2023-01-23 17:15:54 +01:00
Igor Petruk
c116ef8567
Update Speaker Notes in modern.md (#206)
Adding a mention of LSP and rust-analyzer
2023-01-23 17:12:24 +01:00
Igor Petruk
543cad59e4
Update result.md (#250)
* Update result.md

Adding a speaker note that `Result` documentation is a recommended read.

* Adding a note why `Result` encourages error checking.

* Wordsmithing

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 13:47:41 +00:00
Igor Petruk
10bd1616cb
Update iterator.md (#244)
* Update iterator.md

Adding a Speaker Note emphasizing that all most all functional programming toolbox over collections can be found in the `Iterator` documentation.

* Wordsmithing

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 13:45:45 +00:00
Igor Petruk
6b75f9e69c
Update impl-trait.md (#249)
Adding an extra speaker note why `impl Display` is used very appropriately here and what would go wrong if we tried `T: Display`.
2023-01-23 13:41:14 +00:00
Igor Petruk
cde1c433f6
Update trait-bounds.md (#248)
Mentioning `where` clause syntax in speaker notes.
2023-01-23 13:39:23 +00:00
Igor Petruk
b75e713792
Update methods.md (#247)
Adding a Q/A about `impl<T> Point<T>`, why is it specified twice.
2023-01-23 13:38:53 +00:00
Igor Petruk
05cc2ff480
Update from-into.md (#245)
Explaining how those traits are used in practice and when you should use one over another.
2023-01-23 13:18:34 +00:00
Igor Petruk
12c3e2989d
Update match-guards.md (#233)
* Update match-guards.md

Adding more information how match guards are different from simply using "if" inside of the match case, after the case has matched.

* Be consistent about naming of match arms.

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 13:09:32 +00:00
Igor Petruk
91487289d2
Update box-recursive.md (#241)
* Update box-recursive.md

Adding Speaker Notes. This is a high-level guideline what to say, so we can settle on one explanation and review it.
This may be very obvious with the background in some languages, but be very non-obvious in languages that always
use references and never embed structs into structs.

* Fix wording

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 12:54:06 +00:00
Igor Petruk
6b6c553789
Update if-expressions.md (#236)
* Update if-expressions.md

Adding a note about types of `if` branch blocks.

* Fix typo and simplify.

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 12:44:20 +00:00
Andrew Walbran
20e83166f4 Mention alloc too 2023-01-23 12:44:07 +00:00
Igor Petruk
567a570d59 Update std.md
Addition a mention of existence of `core` Standard Library.
2023-01-23 12:44:07 +00:00
Igor Petruk
66509f2f3e
Update for-expressions.md (#238)
If we are introducing `for` loops, I think it is beneficial to show a very basic `for i=0; i < 10; i+=2` too.
2023-01-23 12:04:42 +00:00
Igor Petruk
581f5a4008
Update blocks.md (#235)
Adding the important note about ";" in blocks.
2023-01-23 12:03:06 +00:00
Charisee Chiw
56757566b3
Speaker notes for enums.md (#199)
* Update enums.md

* Update enums.md
2023-01-23 11:58:49 +00:00
Charisee Chiw
be2bb2d4c5
Speaker notes for Method example (#203)
* Speaker notes for Method example

* Update example.md
2023-01-23 11:53:33 +00:00
Igor Petruk
94ed176761
Update destructuring-enums.md (#231) 2023-01-23 11:40:02 +00:00
Igor Petruk
ef119bc0d3
Update receiver.md (#229)
The key takeaway is mutability of receivers and the rules that come with it. It might be a repetition of borrow checker rules, but it is important to know they apply to `self` as to any other variable or argument.
2023-01-23 11:39:38 +00:00
Igor Petruk
c109dabf5f
Update tuple-structs.md (#226)
* Update tuple-structs.md

I am adding more information about newtypes. The speaker can get questions about it or may wish to encourage this great pattern.

* Fix typos and explanation

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 11:38:37 +00:00
Igor Petruk
d1588e4f2f
Update scopes-shadowing.md (#216)
Adding the definition of what shadowing is and how it is different from mutation.
2023-01-23 11:38:11 +00:00
Igor Petruk
71ce061cc2
Update lifetimes-data-structures.md (#224)
* Update lifetimes-data-structures.md

The example is quite simple, but in it's simplicity it may raise the question why do we even need lifetimes in the structs? Isn't it obvious that the referenced value should always outlive the struct? This sentence tries to explain that more complex cases exist.

* Fix typo

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 11:37:38 +00:00
Igor Petruk
473fd02be7
Update sizes.md (#228)
Adding more details in how to control Rust enum size and discriminant values.
2023-01-23 11:33:23 +00:00
Igor Petruk
8dd749da60
Update field-shorthand.md (#227)
Introducing `Self` type that students can encounter in many places and nice to use. It is only mentioned later in the course, but it is not defined currently.
2023-01-23 11:32:46 +00:00
Igor Petruk
356d1cec19
Update boot-library.md (#225)
Adding a link to the Solution.
2023-01-23 11:30:52 +00:00
Igor Petruk
820453ba08
Update structs.md (#232)
Extending a struct example that demonstrates how to change values and how to partially copy structs.
2023-01-23 11:26:22 +00:00
Igor Petruk
4c052d33c8
Update borrowing.md (#222) 2023-01-23 11:24:17 +00:00
Igor Petruk
de4aa3de88
Update moves-function-calls.md (#220)
Additional note helps to understand what move really means. The `name` ownership went fully into the `say_hello`.
2023-01-23 11:23:44 +00:00
Igor Petruk
8c58253217
Update the Speaker Notes of the type-inference.md (#214)
* Update the Speaker Notes of the type-inference.md

I think this is one of the critical moments in understanding Rust. This behavior is different from many static and dynamic programming languages.

* Fix typo

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 11:05:46 +00:00
Igor Petruk
ec7125da2e
Adding a link to Solutions from for-loops.md and extending the answer to the bonus questions. (#213)
* Update for-loops.md

* Update solutions-morning.md
2023-01-23 11:05:36 +00:00
Igor Petruk
4760295030
Update Speaker Notes for compound-types.md (#207)
It could be a "gotcha" moment for readers when they associate `()` with `void` from, say, C++.
2023-01-23 11:04:38 +00:00
Igor Petruk
dc894b1e9d
Update arc.md (#255)
Adding more information about `Arc`: what it stands for, costs and that reference cycles can occur.
2023-01-23 10:57:10 +00:00
Igor Petruk
8107a0ea2b
Update scoped-threads.md (#253)
Adding speaker notes explaining why scoped threads work and what borrowing rules apply.
2023-01-23 10:56:32 +00:00
Igor Petruk
77a60d4101
Update send-sync.md (#258)
Adding notes that these traits are not to be implemented directly. Yet they are still to be used as normal traits in generic constraints.
2023-01-23 08:51:41 +01:00
Igor Petruk
905d0a067e
Update implicit-conversions.md (#210)
I suggest to clarify that you only need to implement `From` and nobody really implements `Into` as soon as `From` is implemented.

I decided to add a separate paragraph after the `i8` and `i16` example, as they provide intuitive understanding of reverse relationship between `From` and `Into`. Alternatively trying to explain `From` and `Into` in generic way sounds more confusing than just adding this sentence after the specific example.
2023-01-21 14:20:14 +00:00
Igor Petruk
25a32abef7
Update Speaker Notes for compile-time.md (#205)
* Update Speaker Notes for compile-time.md

The definition of memory leaks is indeed blurry, so it is important not have right expectations about this particular kind of error.

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-21 15:13:51 +01:00
Igor Petruk
79decc5540
Update Speaker Notes for what-is-rust.md (#204) 2023-01-21 14:10:00 +00:00
Charisee Chiw
d4c0099781
Added speaker notes to enum sizes (#201)
* Added speaker notes to enum sizes

* Update sizes.md

Just formatting

Co-authored-by: Fabian Bornhofen <fbornhofen@google.com>
2023-01-20 22:55:30 +01:00
Andy George
492037641e
fix Cargo.toml syntax (#190) 2023-01-20 11:28:38 +01:00
Robin Stringer
2d4340f3eb
Speaker notes for 6.5 Functions
Adds speaker notes covering functions basics (declaration parameters, return values, the 'unit' type.
2023-01-19 12:16:43 +00:00
Marko Zagar
6bda89f34e Clarification on references 2023-01-19 10:51:35 +00:00
Marko Zagar
529d4bf20c Speaker note tweaks for compound types 2023-01-19 10:51:35 +00:00
Marko Zagar
7a2ffda266 Mention ADT and zero-cost abstractions among modern features 2023-01-19 10:51:35 +00:00
Martin Geisler
48ec773052 Add support for translations
This implements a translation pipeline using the industry-standard
Gettext[1] system.

I picked Gettext for the reasons described in [2] and [3]:

* It’s widely used in open source software. This means that there are
  graphical editors which will help you in editing the `.po` files. An
  example is Poedit[4], which is available for all major platforms.

  There are also many online systems for doing translations. An
  example is Pontoon[5], which is used for the Rust website itself. We
  can consider setting up such an instance ourselves.

* It is a light-weight yet structured format. This means that nothing
  changes with regards to how you update the original English text. We
  can still accept fixes and PRs like normal.

  The structure means that translators can see exactly which part of
  the course they need to update after a change. This is completely
  lost if you simply copy over the original text and translate it
  in-place in the Markdown files.

The code here only adds support for translations. They are not yet
tested, published or used for anything. Next steps will be:

* Add support for switching languages via a bit of JavaScript on each
  page.

* Update the speaker notes feature to support translations (right now
  “Speaker Notes” is hard-coded into the generated HTML). I think we
  should turn it into a mdbook preprocessor instead.

* Add testing: We should test that the `.po` files are well-formed. We
  should also run `mdbook test` on each language since the
  translations can alter the embedded code.

Fixes #115.

[1]: https://www.gnu.org/software/gettext/manual/html_node/index.html
[2]: https://github.com/rust-lang/mdBook/pull/1864
[3]:
https://github.com/rust-lang/mdBook/issues/5#issuecomment-1144887806
[4]: https://poedit.net/
[5]: https://pontoon.rust-lang.org/
2023-01-18 16:12:53 +01:00
Martin Geisler
8e3941d2e6
Fix close tag on keyboard shortcut page (#179) 2023-01-18 10:57:31 +00:00
Martin Geisler
0324cd2b27
Merge pull request #176 from google/testing
Fix Rustdoc comment.
2023-01-17 17:32:39 +01:00
Andrew Walbran
8f6dcf35f5 Fix Rustdoc. 2023-01-17 16:07:10 +00:00
Zhizhen He
51ad97a8df
Fix typo (#173) 2023-01-17 11:42:31 +00:00
Brandon Pollack
13da3112e9
Ownership speaker notes (#172)
* ownership speaker notes

Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-01-17 08:09:14 +00:00
Andrew Walbran
1c7ce1cac6 Use a consistent order in memory layout of trait objects example. 2023-01-16 16:11:31 +00:00
Andrew Walbran
5cbb8d4c27 Add speaker notes about closures. 2023-01-16 16:11:31 +00:00
Andrew Walbran
a1861ef900 Add speaker notes for impl Trait. 2023-01-16 16:11:31 +00:00
Andrew Walbran
832c7e9963 Add speaker notes for Iterator, and an example using FromIterator. 2023-01-16 16:11:31 +00:00
sahennenkamp
93b20be600 Hint towards making library mut
Follow up to https://github.com/google/comprehensive-rust/pull/137
Gives the student a hint that it's okay to edit variables within main.
2023-01-16 11:06:40 +01:00
Yauheni Baltukha
4c8d85dc88 Fix typo in rust.md 2023-01-16 11:06:40 +01:00
Robin Stringer
71c68a6996 Adds speaker notes for 6.4.1. String vs str
Adds speaker notes including:
-Brief explanation of &str, String type
-String::from and String::new
-push_str method
2023-01-16 11:06:40 +01:00
Fabian Bornhofen
35893e2bc6
Update src/ownership/lifetimes-data-structures.md
Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-13 12:47:15 +01:00
Fabian Bornhofen
53706056e3
Update src/ownership/lifetimes-data-structures.md
Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-13 12:47:01 +01:00
Fabian Bornhofen
77f24ffab7 Add speaker notes for lifetimes-data-structures.md 2023-01-12 19:36:40 +01:00
Fabian Bornhofen
9c652d06aa Add speaker notes for moves-function-calls.md 2023-01-12 18:23:57 +01:00
Martin Geisler
67b65c5ee8
Simplify language in speaker notes 2023-01-12 17:13:46 +01:00
Robin Stringer
d85643d5ac
Update src/basic-syntax/slices.md
Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-12 16:11:46 +00:00
Robin Stringer
f4b651456c
Speaker notes to 6.4 Slices
Brief digest of the slice type, including mentions of borrowing, range syntax and lifetimes.
2023-01-12 15:53:16 +00:00
Fabian Bornhofen
3dd03bbd65 Re-add link that is still in use 2023-01-12 12:33:03 +01:00
Fabian Bornhofen
92dafcb676
Merge pull request #158 from brandonpollack23/stackheap
Add speaker notes to stack and heap pages
2023-01-12 11:53:54 +01:00
Fabian Bornhofen
45e57e9359
Capitalization in stack.md 2023-01-12 11:51:37 +01:00
Fabian Bornhofen
7203bb8a65
Capitalization in src/memory-management/rust.md 2023-01-12 11:50:28 +01:00
Fabian Bornhofen
e8ed8cb5de Clean up playground link in borrowing.md 2023-01-12 11:32:11 +01:00
Fabian Bornhofen
83cd7ab67b Fix typo in borrowing.md 2023-01-12 11:27:57 +01:00
Fabian Bornhofen
a3ec024fba Fix formatting in compound-types.md 2023-01-12 11:26:48 +01:00
Ilya Grigoriev
acdf00ae6e Add speaker notes about error examples 2023-01-11 18:14:58 -08:00
Brandon Pollack
f750f75db6 stackheap notes 2023-01-12 11:12:53 +09:00
Fabian Bornhofen
a8fb8ad2b6
Merge pull request #120 from google/running-the-course
Add instructions about how to run the course
2023-01-11 18:28:22 +01:00
Fabian Bornhofen
0b7b69df10
Merge pull request #152 from google/solution-speaker-notes
Add speaker notes to exercise pages
2023-01-11 16:46:55 +01:00
Martin Geisler
d037d7b5c7
Merge pull request #133 from rastringer/patch-1
Adds speaker notes to Compound Types section
2023-01-11 15:51:53 +01:00
Martin Geisler
b6bec18875
Clarify that "fixed" means "compile-time constant" 2023-01-11 15:49:10 +01:00
Robin Stringer
41bb8acf3f
Removes out of bounds checks for simplicity
Removes the out of bounds checks to keep the notes simple.
2023-01-11 14:35:20 +00:00
Martin Geisler
6019a946d9
Merge pull request #154 from fbornhofen/speaker-notes
Speaker notes for box.md, rc.md, option-result.md
2023-01-11 14:49:03 +01:00
Martin Geisler
6b8ee3c979
Fix typo 2023-01-11 14:47:34 +01:00
Fabian Bornhofen
02e1f4b879 Add speaker notes for option-result.md 2023-01-11 14:19:21 +01:00
Fabian Bornhofen
dd194f07c9 Add speaker notes for rc.md 2023-01-11 14:04:30 +01:00
Fabian Bornhofen
5256d9c3fd Add speaker notes for box.md 2023-01-11 13:29:43 +01:00
Filipe Casal
de9d67205e
Fix typo on Luhn exercise 2023-01-11 12:11:06 +00:00
Martin Geisler
1085e9c20b Add speaker notes to exercise pages
The notes link to the corresponding solutions.
2023-01-11 12:49:59 +01:00
Martin Geisler
587645db6c
Clarify default vs debug output. 2023-01-11 10:49:21 +01:00
Martin Geisler
d1422e93c2
Merge pull request #149 from fbornhofen/speaker-notes-string
Add speaker notes for string.md
2023-01-10 19:55:59 +01:00
Martin Geisler
da81dfa07f
Simplify char count 2023-01-10 19:54:48 +01:00
Martin Geisler
08af7574bb Add instructions about how to run the course
I think we need a chapter “before the course” which gives people some
background information about how to run the course. This is the start
of this chapter, we might expand it in the future as we find more
things to communicate here.
2023-01-10 19:12:57 +01:00
Fabian Bornhofen
b2b11257f5 Add speaker notes for string.md 2023-01-10 19:06:06 +01:00
Martin Geisler
4e746482f2
Merge pull request #148 from fbornhofen/speaker-notes-if-let
Add speaker notes for if-let-expressions.md
2023-01-10 18:58:53 +01:00
Martin Geisler
1b3eaec5e7
Merge pull request #141 from brandonpollack23/static_const
Added notes, runtime constant eval, and footnoes to static-and-const.md
2023-01-10 18:53:46 +01:00
Martin Geisler
0d5232358b
Remove dangling footnote 2023-01-10 18:52:37 +01:00
Fabian Bornhofen
d42f0dcd46 Add speaker notes for if-let-expressions.md 2023-01-10 18:30:22 +01:00
Martin Geisler
20c0a37949
Merge pull request #139 from brandonpollack23/rust_ecosystem
Add more info and footnotes to rust-ecosystem.md
2023-01-10 17:51:44 +01:00
Martin Geisler
637b785714
Merge pull request #138 from brandonpollack23/cargo_page
Added some more detail on rustup.
2023-01-10 17:50:56 +01:00
Martin Geisler
3eee86f76d
Merge pull request #143 from fbornhofen/speaker-notes-copy-2
Rephrase copy/clone speaker notes
2023-01-10 17:47:27 +01:00
Martin Geisler
c994340a8f
Merge pull request #142 from fbornhofen/speaker-notes-fbornhofen
Add example for underscore syntax with generics (type-inference.md)
2023-01-10 17:46:20 +01:00
Martin Geisler
6b874844ca
Merge pull request #144 from fbornhofen/speaker-notes-rvo
Add speaker notes about RVO in borrowing.md
2023-01-10 17:45:39 +01:00
Martin Geisler
9448ae3e19
Merge pull request #146 from fbornhofen/speaker-notes-variant-payloads
Add speaker notes for variant-payloads.md
2023-01-10 17:44:49 +01:00
Fabian Bornhofen
8d2fb11adc Expand enum sizes example and add speaker notes 2023-01-10 17:36:16 +01:00
Fabian Bornhofen
c91cc629d5 Add speaker notes for variant-payloads.md 2023-01-10 16:46:57 +01:00
Fabian Bornhofen
91b8d33a99 Add speaker notes for shared and unique borrows 2023-01-10 15:51:56 +01:00
Fabian Bornhofen
d157b54fd4 Add speaker notes about RVO in borrowing.md 2023-01-10 15:04:17 +01:00
Brandon Pollack
0eec153927 move to reference links 2023-01-10 22:21:13 +09:00
Brandon Pollack
c2c3d48920 moved footnotes to speaker notes 2023-01-10 22:17:18 +09:00
Brandon Pollack
8dc2ea4503 Remove superfluous distracting info 2023-01-10 22:12:43 +09:00
Brandon Pollack
b5a7c9cdcc
clarify static details
Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-01-10 05:05:45 -08:00
Brandon Pollack
a532c23c60
Simplify wording of constexpr/const relation
Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-01-10 05:05:26 -08:00
Brandon Pollack
1196622b7a Removed magic incantation that should just be behind the link 2023-01-10 22:03:47 +09:00
Fabian Bornhofen
4fd8a2ca62 Rephrase bullet point in copy/clone slide 2023-01-10 14:01:08 +01:00
Brandon Pollack
3eecb4bef6
Add time of writing to reflect current status quo that might change
Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-01-10 05:00:59 -08:00
Fabian Bornhofen
87b26c78c0 Add not about C++ copy constructors 2023-01-10 13:57:15 +01:00
Fabian Bornhofen
65837087c9 Copy, clone speaker notes: phrase as sentences i/o questions 2023-01-10 13:55:43 +01:00
Fabian Bornhofen
d1a3290cd6 Add reference to collect, FromIterator 2023-01-10 11:40:02 +01:00
Fabian Bornhofen
b1069f863c Add example for underscore syntax with generics (type-inference.md) 2023-01-10 11:30:48 +01:00
Martin Geisler
e29c3bfb99
Merge pull request #123 from ilyagr/username_or_error
Error handling: clarify printing of Result
2023-01-10 10:21:43 +01:00
Martin Geisler
e43dec24fd
Tighten language 2023-01-10 09:29:57 +01:00
Brandon Pollack
89ddb2c197 Added notes, runtime constant eval, and footnoes to static-and-const.md 2023-01-10 13:41:31 +09:00
Brandon Pollack
d15a653ed8 Added some speaker notes to variables.md 2023-01-10 13:27:39 +09:00
Brandon Pollack
6a2889d8ce Add more info and footnotes to rust-ecosystem.md 2023-01-10 13:10:16 +09:00
Brandon Pollack
cec5e6d64e Added information on Jetbrains 2023-01-10 12:42:38 +09:00
Brandon Pollack
4172e7587c Added some more detail on rustup.
Rusutp is the reccomended way to install rust and maintained by the core
team.

I added some organization and suggested that that be the method of
installation.
2023-01-10 12:36:51 +09:00
Martin Geisler
bee9cdab92
Merge pull request #136 from fbornhofen/speaker-notes-variables
Add speaker notes for scopes-shadowing.md
2023-01-09 18:44:29 +01:00
Martin Geisler
c5824aece0
Merge pull request #134 from fbornhofen/speaker-notes-fbornhofen
Speaker notes for lifetimes-function-calls.md
2023-01-09 18:43:56 +01:00
Fabian Bornhofen
2ec7bdf15d Ignore code block that deliberately contains an error 2023-01-09 17:36:58 +01:00
Fabian Bornhofen
3a4d5d4c26 Add complete code block for lifetimes example 2023-01-09 17:32:37 +01:00
Fabian Bornhofen
77d3ac01e7 Add speaker notes for scopes-shadowing.md 2023-01-09 17:21:54 +01:00
Fabian Bornhofen
ba09385c4a Add bullet point about mutable references 2023-01-09 16:54:14 +01:00
Fabian Bornhofen
512dedf729 Make instructions in lifetimes-function-calls.md more precise 2023-01-09 16:31:09 +01:00
Fabian Bornhofen
597c875442 Add speaker notes to lifetimes-function-calls.md 2023-01-09 16:27:10 +01:00
Robin Stringer
6fac027dd6
Updates PR with code formatting
Backticks for inline and single line code blocks / examples.
2023-01-09 14:42:27 +00:00
Robin Stringer
9cd5d25821
Adds speaker notes to Compound Types section
Speaker notes for 6. Basic Syntax, 6.2 Compound Types section.
Briefly explains arrays and tuples properties.
Adds option for instructor to check for out of bounds errors using assert!().
2023-01-09 14:18:37 +00:00
Martin Geisler
3ff2d5f43a
Merge pull request #118 from google/exercise-code-snippets
Explain why exercises are not editable
2023-01-09 14:42:54 +01:00
Martin Geisler
affb2526fe Explain why exercises are not editable
From a discussion in #23.
2023-01-09 14:41:48 +01:00
Martin Geisler
e835ee6cdf Add notes to threads.md
From the discussion in #63.
2023-01-09 14:32:04 +01:00
Martin Geisler
f4b753b7c5 Speaker notes for “Rust Ecosystem” 2023-01-09 14:27:13 +01:00
Martin Geisler
62d206506f Speaker notes for “Running Cargo Locally” 2023-01-09 14:27:13 +01:00
Martin Geisler
3db19fd2e5 Speaker notes for “Using Cargo” 2023-01-09 14:27:13 +01:00
Martin Geisler
b1e11304a7 Speaker notes for “Runtime Guarantees” 2023-01-09 14:27:13 +01:00
Martin Geisler
ba3c6b0de9 Speaker notes for “Modern Features” 2023-01-09 14:27:13 +01:00
Martin Geisler
cf505e99cd Rephrase “No memory leaks”
The footnote was added before we had support for speaker notes. It’s
too large to show on the screen during a classroom presentation, so it
has now been moved to the speaker notes.

I tried to keep the information intact, including keeping the word
“mostly” on the slide.
2023-01-09 14:26:47 +01:00
Martin Geisler
a7adf49002 Speaker notes for “Why Rust?” 2023-01-09 14:26:47 +01:00
Martin Geisler
50b0ad76eb Introduce speaker notes on welcome page 2023-01-09 14:24:02 +01:00
Fabian Bornhofen
0723135dc6 Remove bullet point about printing p1 2023-01-09 13:39:39 +01:00
Fabian Bornhofen
45bc1233d2 s/twice/again/ 2023-01-09 13:37:06 +01:00
Fabian Bornhofen
e213f9dbd3 Add speaker notes to copy-clone.md 2023-01-09 13:20:00 +01:00
Zhizhen He
b287aeada1
Fix typo in structure.md 2023-01-09 02:01:28 +08:00
Martin Geisler
7e0670e6b7
Merge pull request #126 from marshallpierce/patch-2
Use rustls instead of openssl
2023-01-07 14:50:18 +01:00
Michael Lee
3f4ae0606d Update broken links 2023-01-07 15:38:40 +08:00
Marshall Pierce
b67908698f Use rustls instead of openssl
Using the `rustls-tls` feature on reqwest will use rustls and ring, which should compile on any system.
2023-01-06 15:22:40 -07:00
Ilya Grigoriev
68eed5b4f2
Error handling: clarify printing of Result
Two examples may print either `Ok(username)` or `Err(error)`.
This commit clarifies this fact.
2023-01-06 12:35:05 -08:00
Marshall Pierce
0a9dd33e58
Create an empty rather than pre-allocating
It might give the impression that you can only write to a Vec that has capacity, when in fact Vec's Write impl will grow the storage as needed. While pre-allocating is probably a good efficiency win in many circumstances, I think it's probably worth minimizing the number of concepts in play in this example.
2023-01-06 09:47:42 -07:00
鐘天楽
c8f626e573
for-loop bonus explanation (#108)
* for-loop bonus explanation
2023-01-06 10:15:16 +01:00
Martin Geisler
9a68434cac
Merge pull request #49 from ilyagr/patch-1
`anyhow`: Remove `ReadUsernameError::IoError`
2023-01-05 15:57:17 +01:00
Arman Yessenamanov
e1c670c4a8
Fix a typo in result.md
"have already see" -> "have already seen"
2023-01-05 14:41:40 +06:00
Martin Geisler
8feb6b4ad4
Merge pull request #109 from rhapsodyai/fixes-99
Fixes: #99
2023-01-05 09:08:03 +01:00