1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-25 23:49:54 +02:00

840 Commits

Author SHA1 Message Date
Martin Huschenbett
97a47cab78
Parse into data structures in protobuf example ()
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?
2023-12-15 10:00:50 -05:00
Dustin J. Mitchell
085cbf2c1e
Update expression-evaluation exercise: more patterns, more enums ()
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 .
2023-12-14 15:22:28 +00:00
Martin Huschenbett
302a03bbe3
Remove unnecessary syntax in protobuf example ()
`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`.
2023-12-14 16:02:40 +01:00
rickyclarkson
c7a86ca584
Fixing a typo () 2023-12-13 18:26:34 -05:00
Dustin J. Mitchell
afea94b1ed
Use a type alias in binary tree exercise ()
As suggested by @marshallpierce and @hurryabit
2023-12-13 19:53:35 +00:00
Martin Huschenbett
c6973018c6
Fix typo in lifetime annotations section ()
The code example was meant to be `editable` but was marked as
`eitable`.
2023-12-13 13:41:32 -05:00
Martin Huschenbett
ee826ef742
Use cmp + match in binary tree example ()
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>
2023-12-13 13:39:23 -05:00
Martin Huschenbett
f37aeac3ca
Remove unnecessary ref mut in binary tree exercise ()
There's no need for the `ref mut` in the pattern. So, let's just drop
it for the sake of simplicity.
2023-12-13 12:34:18 -05:00
Martin Huschenbett
ce081b12f9
Rename test module into tests in smart pointer exercise ()
If I'm not mistaken, the naming convention for modules containing only
tests is to call them `tests` (rather than `test`).
2023-12-13 12:33:31 -05:00
Dustin J. Mitchell
9563f055e2
Minor updates based on instruction ()
This contains some minor updates from .

---------

Co-authored-by: Marshall Pierce <575695+marshallpierce@users.noreply.github.com>
2023-12-13 12:51:34 +00:00
Chayim Refael Friedman
86289b4814
Remove an incorrect note ()
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).
2023-12-12 11:29:50 -05:00
Chayim Refael Friedman
c342a74b3e
Having a Vec allows accessing mutating slice methods, too ()
I don't know why "read-only" was added.
2023-12-12 10:02:10 -05:00
Marshall Pierce
e41ab44a38
More tiny fixes () 2023-12-11 16:13:54 -05:00
Dustin J. Mitchell
e765159be1
Clarify completion condition for elevator exercise ()
Addresses the first part of .
2023-12-11 19:12:40 +00:00
Lukasz Anforowicz
f04e277744
Chromium: Add redox_syscall to speaker notes for the third-party exercise. ()
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>
2023-12-11 07:21:53 -08:00
Kanta Yamaoka (山岡幹太)
d62f2c4583
Add trait bounds to glossary ()
Hi, this is a tiny MR to add glossary entry for "trait bound". Could you
someone review it? I'm open to suggeston, too. Thank you!
Context:
https://github.com/google/comprehensive-rust/pull/1436#discussion_r1394298992
2023-12-10 17:05:11 +01:00
Adrian Taylor
4a576fd436
Update depending-on-a-crate.md ()
Fix typo
2023-12-08 07:07:13 -08:00
Lukasz Anforowicz
89b41555eb
Title-casing in section titles ()
Fixes https://github.com/google/comprehensive-rust/issues/1552
2023-12-07 18:06:18 -08:00
Martin Geisler
1ec2e8db9e
Expand "Docs" plus light copy-editing ()
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).
2023-12-07 20:04:36 +00:00
Martin Geisler
c080de8253
Simplify enums a little ()
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>
2023-12-07 16:15:57 +00:00
Adrian Taylor
cc8405d04f
Chromium exercise solutions ()
The main thing in this CL is a link to exercise solutions but there are
a couple of other very minor tweaks.
2023-12-06 19:26:41 +00:00
Martin Geisler
91cb5b2048
Fix outdated references to “three days” ()
Rust Fundamentals is now a four-day course.
2023-12-06 12:55:34 -05:00
Marshall Pierce
9efad3212f
More minor fixes ()
- Fix compile errors and warnings in error handling example
- Tweak iteration example so that it correctly visits the first grid
coordinate
2023-12-06 12:53:06 -05:00
Adrian Taylor
59a0faba83
Update policy.md ()
Fix formatting of "C++"
2023-12-06 09:55:42 -05:00
Martin Huschenbett
f08c537007
Use type annotation instead of turbo fish in method chapter ()
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.
2023-12-06 14:16:01 +00:00
Martin Huschenbett
70efef4f38
Use Self to create struct in method chapter ()
If I'm not mistaken, it's idomatic to use `Self` in a struct constructor
rather than the name of the struct.
2023-12-06 14:08:56 +00:00
Marshall Pierce
6c5061bb90
Various small fixes ()
Plus one more substantial comment on casting.
2023-12-05 18:06:42 -05:00
Lukasz Anforowicz
8f9902cc3e
Chromium: new subsection about gtest tests () 2023-12-05 10:39:02 +00:00
Xavier Carol
7d10518b24
Update interior-mutability.md ()
fix typo copmile-time
2023-12-04 18:36:35 +00:00
Lukasz Anforowicz
24b132b67a
Chromium: expanding CXX error handling section. () 2023-12-04 08:03:17 -08:00
Martin Geisler
a277e7b922
Fix mock example and move it to a file for testing ()
I swear I tested this in an actual Rust file, but I somehow messed up
when copy-pasting it into the example. The code is now in the test file
so it will be correct.

Why is the indentation wrong? Because of

  https://github.com/rust-lang/mdBook/issues/1564

The indentation is not kept by the included content, which breaks the
Markdown.
2023-12-01 23:19:10 +01:00
Dustin J. Mitchell
fbd79e36e7
Remove incorrect comment about moving arrays ()
Fixes .
2023-12-01 13:37:37 -05:00
Lukasz Anforowicz
584c957d69
Fix spelling of CXX and Cargo (mostly in the Chromium part). () 2023-12-01 10:21:47 -08:00
Martin Geisler
53baee82e3
Re-apply formatting to SUMMARY.md ()
With the latest version of mdbook-i18n-helpers, we now have support for
formatting in the `SUMMARY.md` file. This allows us to revert the
changes made in  when we first introduced the translation support.

This also aligns a few headings to match the heading in the outline.
While this isn’t strictly necessary, it removes a bit of work for the
translators.
2023-12-01 13:20:28 -05:00
Lukasz Anforowicz
9d21d5648d
Use std::string_view (not just const char*) as an analogy of &str. () 2023-12-01 10:17:27 -05:00
Martin Geisler
f837afa034
Explain that mocking.md has AOSP recommendations ()
A follow-up to .
2023-12-01 10:10:27 -05:00
Martin Geisler
d0bab8302c
Add slide to show the Mockall crate in action ()
As more and more Android teams start using Rust, the question of "How to do mocking?" has come up more frequently. Right now, we don't have a good answer to those teams, AOSP doesn't have any mocking framework available. That will change soon with the import of Mockall and this slide is part of the supporting documentation that we can point teams to.
2023-12-01 09:36:06 -05:00
Ning Chen
3f7b6d4ad7
Fix adb push command ()
```
$ adb push "$ANDROID_PRODUCT_OUT/system/bin/hello_rust /data/local/tmp"
adb: push requires <source> and <destination> arguments
```

---------

Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-12-01 10:05:46 +00:00
Lukasz Anforowicz
1ab68d6ac1
Chromium: minor tweaks in reviews-and-audits.md. () 2023-12-01 09:34:04 +01:00
Lukasz Anforowicz
547de2b161
Chromium: Expand speaker notes for Rust Analyzer demo () 2023-12-01 09:25:29 +01:00
Lukasz Anforowicz
f3e045ddf4
Chromium: Enumerate automation benefits of cxx + other minor tweaks. () 2023-12-01 09:24:59 +01:00
Lukasz Anforowicz
c7fb26fe0e
Chromium: Revise cargo.md, focusing on when to prefer cargo over gn. () 2023-12-01 09:23:58 +01:00
Lukasz Anforowicz
02d0b5d01a
Chromium: fix path of String::from_utf16 () 2023-12-01 09:21:20 +01:00
Martin Geisler
97e130271d
Fix Markdown in build-rules.md ()
The mixing of HTML and Markdown breaks our translation pipeline: we see
the HTML and fail to parse things correctly.

This might be https://github.com/google/mdbook-i18n-helpers/issues/97,
but I'm not 100% sure.

The fix is to make put the HTML on its own line: then the Markdown is
parsed again inside.

Fixes .
2023-11-30 06:55:03 -08:00
J.Lunz
1ba88ba72e
Fix Fibonacci numbers example ()
The exercise has n <= 2 for the base case, but it is n < 2 in the
solution.
You currently get fib(n) = 10946 for n = 20, but it should be 6765.
2023-11-30 09:46:13 -05:00
Martin Geisler
9905b21c26
Fix ANCHOR_END in exercise.rs ()
This fixes the duplicated content.

Fixes .
Fixes .
2023-11-30 09:34:41 -05:00
Dustin J. Mitchell
a73c830e45
Add course and session markers for deep-dives ()
This doesn't add any timing information. The authors of each deep-dive
can do that separately.

Fixes .
2023-11-30 09:26:21 -05:00
Martin Geisler
8862ab6530
Add slide on GoogleTest ()
We expect Android engineers to start using this crate going forward.
2023-11-30 14:57:00 +01:00
Ning Chen
ca0bfedac6
Update setup.md ()
```
$ lunch aosp_cf_x86_64_phone-userdebug

Invalid lunch combo: aosp_cf_x86_64_phone-userdebug
Valid combos must be of the form <product>-<release>-<variant>
```
2023-11-30 13:36:42 +00:00
Dustin J. Mitchell
6d19292f16
Comprehensive Rust v2 ()
I've taken some work by @fw-immunant and others on the new organization
of the course and condensed it into a form amenable to a text editor and
some computational analysis. You can see the inputs in `course.py` but
the interesting bits are the output: `outline.md` and `slides.md`.

The idea is to break the course into more, smaller segments with
exercises at the ends and breaks in between. So `outline.md` lists the
segments, their duration, and sums those durations up per-day. It shows
we're about an hour too long right now! There are more details of the
segments in `slides.md`, or you can see mostly the same stuff in
`course.py`.

This now contains all of the content from the v1 course, ensuring both
that we've covered everything and that we'll have somewhere to redirect
every page.

Fixes .
Fixes .

---------

Co-authored-by: Nicole LeGare <dlegare.1001@gmail.com>
Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-11-29 16:39:24 +01:00