1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-19 20:13:06 +02:00
Commit Graph

1516 Commits

Author SHA1 Message Date
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
Martin Geisler
438c16607d
Add theme generated with mdbook init --theme (#189)
This will allow us to customize the appearance more easily: we can
move the GA logic into the theme (to reduce load times and to simplify
the JS injection logic). We can also add new elements, which is what I
will do next.

The mdbook theme can be added incrementally: if we don’t add a file to
our theme folder, we will get the corresponding file from mdbook.
2023-01-25 21:31:22 +01:00
Kostis Andrikopoulos
4fed580efa
Add trailing backslash for multiline command (#277)
There were some backslashed missing in the command to serve the
translated book. Thus the shell would execute the lines one after the
other, instead of as one command.

This lead to the environment variables not actually being set, and thus
the non-translated version was served anyway.
2023-01-25 18:26:58 +01: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
Martin Geisler
bad5cc9f68
Publish translations to /xx subdirectories (#264)
This publishes translations (currently only the Danish translation) to
subdirectories named after the ISO 639-1 language code: “da/” for
Danish, “ko/” for Korean, etc.

The list of translation is an explicit list to make it easy for us to
enable/disable translations without being tied to the files in po/.
This allows us to experiment with a translation without publishing it
immediately.

I propose that we eventually move the English pages to an “en/”
directory for symmetry with the other locales. However, for now, the
pages remain at the room of our site (which works fine since we don’t
have a subdirectory named “en/” in the course).
2023-01-24 12:07:04 +01:00
Martin Geisler
46f25ac891
Set the site-url to fix 404 page on GitHub Pages (#263)
This fixes the 404 page on GitHub Pages: the default is `/`, but we’re
hosting the site from a subdirectory because of how the repository is
setup.

Fixes #178.
2023-01-24 12:03:46 +01: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
Martin Geisler
1f37933b8b
Extract common build steps to composite actions (#242)
* Extract common build steps to composite actions

This allows us to repeat ourselves less across the different jobs.

I also tested using a “reusable workflow” to factor out the common
steps. However, this starts a separate job without a shared
filesystem, which in turn requires us to upload/download artifacts
when we want to use them in several jobs. The artifacts are downloaded
one-by-one and this adds delays and extra steps to all jobs.

* Move Rust cache setup to its own build step

This made it easy to consistently setup the caching of our nested
projects via the “workspacs” config key.
2023-01-23 17:08:29 +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