In https://github.com/google/comprehensive-rust/pull/1591, I changed the
implementation of the protobuf example significantly. However, I forgot
to update a comment which is referred to the old style of
implementation. I'll this slip here.
The solution to the modules exercise comes with a bunch of files. I
think it would help the students to get a quick overview of the
directory structure we've chosen first.
Explain what traits `thiserror::Error` derives.
Explain how `.context()` and `.with_context()` operate on types that are
not aware of `anyhow`.
Resolves#1597.
`let Some(x) = E else { return None; }` is equivalent to
`let Some(x) = E?`. That latter is shorter and more idiomatic, so let's
use that.
A pattern of the form `c @ P1 | c @ P1` has the disadvantage that the
name `c` is repeated. Let's replace it with `c @ (P1 | P2)`.
An `x: Option<Result<T, E>>` can be handled more succinctly with
`x.ok_or(...)??`.
This is a suggestion for how we could make the protobuf exercise at the
end of day 3 better.
Generally speaking, the idea is to parse the protbuf bytes into data
types instead of only printing the parsing outcome to the console. To
make this a little more realistic, we also introduce a trait
`ProtoMessage` for message types.
I think this is more instructive than the current example. In
particular, we get to mess around with lifetimes. This might be a little
more complicated but can be a great opportunity for the students to tie
together different things they've learnt in the course so far.
What do you all think?
This modifies the exercise to lean more into interesting `match`
statements. It also uses the standard `Result` type, based on feedback
that students could understand it sufficiently at this point in the
course.
Addresses #1565.
`Ok(x?)` has the same outcome as `x` and save an unpacking/repacking
cycle.
`x as usize` has no effect when `x` already has type `usize`.
In `x < 4usize` the `usize` is unnecessary when `x` already has type
`usize`.
Currently, the implementation uses if-then-else chains and `<` and `>`.
This is not the most idiomatic Rust. Instead, we can use `cmp` and
`match` to make the code easier to read.
---------
Co-authored-by: Dustin J. Mitchell <djmitche@google.com>
This reverts #1490 due to errors seen in
https://github.com/google/comprehensive-rust/actions/runs/7188648811/job/19590765217.
The error says
Get:23 http://azure.archive.ubuntu.com/ubuntu jammy/main amd64
libc6-dev-arm64-cross all 2.35-0ubuntu1cross3 [1546 kB]
Fetched 41.7 MB in 1s (46.1 MB/s)
E: Failed to fetch
mirror+file:/etc/apt/apt-mirrors.txt/pool/main/b/binutils/binutils-aarch64-linux-gnu_2.38-4ubuntu2.3_amd64.deb
404 Not Found [IP: 52.147.219.192 80]
E: Unable to fetch some archives, maybe run apt-get update or try with
--fix-missing?
Error: Process completed with exit code 100.
This seems less transient than the error which made us remove the `apt
update` calls in #1490.
People are often confused by this: the fact that we can remove the `*`
in the `println!()` is not because the compiler auto-derefs here (it
does not), but because `Display` is implemented for `&T where T:
Display` (a blanket implementation).
Speaker notes for Chromium's third-party crate exercise list the
transitive dependencies that will be downloaded during the exercise.
Before this commit the list was missing the `redox_syscall` crate.
Additionally, the commit sorts the crates to make it easier to compare
with the output of `git status` or `ls`.
---------
Co-authored-by: Martin Geisler <martin@geisler.net>
I don't like shortening words, so I prefer "Documentation" over "Docs".
I find this less jargony and thus easier to read (and potentially also
easier to translate).
Hello, JA translation team!
(https://github.com/google/comprehensive-rust/issues/652)
As part of #1460, I normalized ja.po using mdbook-i18n-normalize 0.3.0.
Steps taken: `mdbook-i18n-normalize`.
I'm open to any feedback or suggestions. Thank you in advance!
This takes out the huge example with lots of macro magic. I don't think
we need it for an introductory course.
I also cleaned up the formatting a little and made sure to distinguish
between types and values.
---------
Co-authored-by: Dustin J. Mitchell <djmitche@google.com>
There must have been a merge conflict at some point which resulted in a
malformed table. The result was that most redirects were blindly ignored
by `mdbook`.
I noticed it for
https://google.github.io/comprehensive-rust/enums.html which stopped
working because of this.
I took out the memory management redirect since we already have a file
where redirect would be (`mdbook` helpfully emits an error in this
case).
If we use a type annotation, we get around explaining the turbo fish,
which isn't trivial without having introduced generics. Type
annotations on the other hand are known already.
Timing information is for a slide as a whole, so we use a sentence like
"This slide and its sub-slides should take about 15 minutes" in the
first chapter in the slide. Subsequent chapters in the same slide do not
need timing information.
Fixes#1552.