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

668 Commits

Author SHA1 Message Date
Wojtek Marczenko
4413b6a28f
Update C manual memory management example (#902)
In C (as opposed to C++) the explicit cast from void* to int* is not required. It is also not idiomatic to do so in C code.

Actual C codebase would use `malloc()` without the cast, and a C++ one (when not using abstractions) a `new int[n]` - both a bit cleaner and less verbose than this example.
2023-07-05 09:37:07 -04:00
Martin Geisler
d27daceda2
Small improvement to wording in box-recursive.md (#905)
The "it" was not clear to our Localization team so I tried to make the sentence a little clearer.
2023-07-05 09:36:07 -04:00
Martin Geisler
d0223ad98b
Mention panics vs wrap-around for integer overflows (#901)
Fixes #894
2023-07-04 11:31:16 +01:00
Victor Costan
6df4ba24dd
Clarify that each philosopher should think/eat 100 times (#900)
Clarify that each philosopher should think/eat 100 times.

Folks who have hazy memories of the philosopher dining problem may
interpret the original instructions as "make each philosopher think and
eat once". This interpretation loses a critical detail, because the
resulting code is highly unlikely to deadlock in practice, even without
breaking the symmetry.
2023-07-04 06:41:54 +00:00
Matt Schulte
76ee72f8e0
Suggest to run day 3 afternoon exercise locally (#882)
* Suggest to run day 3 afternoon exercise locally

Based on feedback from running the class, students found developing
the day 3 afternoon exercise locally was a better experience than
using Playground.

* Update src/exercises/day-3/afternoon.md

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-07-03 06:36:38 +00:00
Mauve
9fc92c5d66
Tweak speaker note about move closures and FnOnce (#859)
* Tweak speaker note about move closures and FnOnce

* Expand closure example, explain move

* Explicitly state traits of example closures
2023-07-03 08:35:03 +02:00
Victor Costan
0c867c952f
"Strings and Iterators" solution that uses let-else (#833)
Add "Strings and Iterators" solution that uses let-else.
2023-06-29 08:52:58 +02:00
Chiin
753e53ad17
Correct print statement in library exercise (#876)
* fix(day 1): correct print statement logic for library emptiness status

* chore: add explicit method print

* chore: change `:` for `->`
2023-06-27 08:22:50 +00:00
Victor Costan
0b4891fb1f
Unified FFI setup for for readdir() on macOS (#857)
Unified FFI setup for for readdir() on macOS.
2023-06-23 15:48:18 +02:00
Martin Geisler
eb6850a1d0
Clarify what "it" is in rust.md (#855) 2023-06-22 14:28:14 +00:00
Martin Geisler
b7469f779e
Update if-let-expressions.md (#854)
The use of "interesting" here made the sentence unclear to our Localization team.
2023-06-22 16:27:34 +02:00
Martin Geisler
aba7fd7f56
Simplify error handling pages (#851)
This makes the `use` statements more consistent and shortens some
variable names.
2023-06-22 16:27:06 +02:00
Martin Geisler
5e42cc3548
Clarify wording in lifetimes.md (#853) 2023-06-22 13:47:27 +01:00
Martin Geisler
186d333227
Run builds on both Mac OS and Linux (#830)
* Run builds on both Mac OS and Linux

This would have helped us catch #570.

* Fix MacOS CI (#848)

* Revert unnecessary changes

The changes might be good, but I want to keep this PR small and
focused. If we end up with the extra `cfg` statements, we should
include a comment to let students know what they do: we’re targeting
people new to Rust, so we need to be careful with explanations.

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-06-22 10:38:41 +02:00
Yonghyun
da569cd7c4
Update default-methods.md (#747)
* Update default-methods.md

This commit resolves two issues.

a) typo: Equal -> Equals
b) update details to comply w/ example source code

* Update src/traits/default-methods.md

Co-authored-by: Edward Liaw <edliaw@google.com>

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
Co-authored-by: Edward Liaw <edliaw@google.com>
2023-06-22 09:05:11 +02:00
Andrew Walbran
c1ad97c659
Fix example to build and run (#838) 2023-06-21 09:48:05 +01:00
vanyabrucker
1ed40f4746
Corrected spelling in bounded.md (#844)
Corrected spellling  bounded.md
2023-06-21 07:12:59 +00:00
Victor Costan
b2ebd8848c
Document the historical reference in the newtypes example (#826)
Document the historical reference in the newtypes example.
2023-06-18 14:37:57 +02:00
Md. Rasel Mandol
5d56a529da
Bengali translation: to link incomplete Bengali translation (#819)
Bengali translation: to link incomplete Bengali translation
2023-06-14 19:37:22 +01:00
Andrew Walbran
54fd2578d3
Add pages about entry point and exception handling on APs (#802)
* Add page about entry point before Rust code.

* Convert tabs to spaces.

mdbook doesn't seem to handle tabs in code properly.

* Add page about handling exceptions.

* More nuanced discussion of Rust Raspberry Pi OS tutorial.

* Add note about EL1 to entry point page too.
2023-06-14 18:27:07 +00:00
Martin Geisler
53fff52b60
Fix link to LICENSE in credits.md (#813)
The link worked fine when GitHub was rendering it — it rewrites the relative path correctly. However, when viewed as the output of `mdbook`, the link pointed to nowhere.
2023-06-14 10:17:29 +01:00
Martin Geisler
d71ea715bb
Fix broken link in for-expressions.md (#812) 2023-06-13 17:43:08 +00:00
Martin Geisler
7c9195ba7a
Fix broken link in Pitfalls of async/await (#811)
Fix broken link in Async Pitfalls
2023-06-13 17:26:56 +00:00
LIU JIE
cf0ce5c0b2
Explain iff in mutex.md (#810)
---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-06-13 12:56:42 +00:00
Martin Geisler
9cf55893ac
Rephrase when send blocks (#792)
* Rephrase when `send` blocks

From a discussion with @hueich in #786: https://github.com/google/comprehensive-rust/pull/786#discussion_r1224850499.
2023-06-11 13:20:33 +00:00
Andreas Hindborg
56c1a6e55e
Add suggestion to use rustup doc (#770)
Suggest to use `rustup doc std::fmt` to open the documentation for `std::fmt`.
2023-06-10 18:01:57 -04:00
Roman
4074b72df8
Fix typo in borrowing.md (#790) 2023-06-10 13:31:46 +00:00
Richard Penman
07a7380b13
Update sizes.md (#775) 2023-06-09 18:00:33 +00:00
Mauve
4b7b5d83ea
Make chat-client reads cancellation safe (#713)
* Make chat-client reads cancellation safe

* Update chat-app references
2023-06-09 16:35:52 +02:00
Mauve
6bf60dadc8
Add information about async cancellation (#716)
* Mention cancellation via select!

* Add a section on async cancellation

* Update cancellation slide, rework example

* Rework select! note about cancellation

* Collapse cancellation comparision to panic and ?

* Don't keep null bytes from incomplete reads
2023-06-09 11:59:12 +02:00
Gershon Papi
305bdbb29a
Fix slices immutable example (#686) 2023-06-06 09:17:55 +00:00
rbehjati
7257052f0c
Minor fixes in async (#771) 2023-06-05 17:12:00 +01:00
TPReal
a7bef92b36
Mentioned the XKCD source of the joke in enums.md (#748)
XKCD is under CC BY-NC 2.5 licence, so it is fair to at least link to the source when reusing a joke.
2023-06-01 18:54:41 +00:00
Florian
ff3fa50597
Update lifetimes.md (#739)
* Update lifetimes.md

Don't think elidied is a word, nothing comes up if I google it. I think omitted works here.

* Update lifetimes.md
2023-05-31 12:55:54 +00:00
Martin Geisler
5de9cdafea
Link to incomplete French, German, and Japanese translations (#730)
These translations all have more than 200 translated messages and
they’ve been updated in the last month.

I suggest we update the list here every few weeks based on input from
the translators: we don’t need a super strict rule here, we just need
interested translators who would like to see their work celebrated.

I suggest we only link completed translations in the language picker
since we have limited space there to differentiate the different
levels of completeness.
2023-05-31 11:55:39 +02:00
Andrew Arnott
cee01c4f6a
Delete double words (#718) 2023-05-29 16:12:44 +00:00
Mauve
7ce92303e9
Clarify Default trait and operators (#717)
* Reword description of Default trait

* Clarify comparision to function type parameters

* Mention heterogenous types for operators
2023-05-29 16:09:09 +00:00
Martin Geisler
0ca16b6fea
Fix typo in compile-time.md (#700)
From #675 via @cydave.
2023-05-26 11:59:12 -04:00
Tanmay Chimurkar
364bb107c0
Missing word in welcome day speaker notes (#699) 2023-05-26 14:51:05 +00:00
Yonghyun
2482fa3c56
Update build_all.sh (#678)
* Update build_all.sh

The path, $ANDROID_BUILD_TOP and/or $ANDROID_PRODUCT_OUT, can contain spaces, which results in error. As long as shell var is not number, it is safe to enclose it with ""

* Enclose full shell word in quotes

This is just a stylistic choice: I find it easier to parse a command line if the full shell word is in quotes.

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-05-25 08:51:12 +00:00
gregory langlais
176d9361d6
Fix a couple typos on the welcome page (#668)
fix a couple typos 

- welcome page typos corrected
2023-05-24 14:15:46 +00:00
Semih Buyukgungor
dabf31d0ce
Fixing some typos (#667)
fix some typos
2023-05-24 08:15:08 +00:00
Dustin J. Mitchell
1c1c367940
Add a sentence about lifetime elision (#663)
add a sentence about lifetime elision
2023-05-23 11:31:35 -04:00
primeagen-rustaceans
cc813973b1
Update receiver.md (#661)
* Update receiver.md

Moving the sentence to the third point and requesting an example of `self` vs `mut self`.

* Update src/methods/receiver.md

Improved the tone of the sentence.

Co-authored-by: Martin Geisler <martin@geisler.net>

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-05-23 12:57:38 +00:00
primeagen-rustaceans
47f6a5dacf
Update lifetimes.md (#660)
Normally developers are aware of the simpler language of implicit vs explicit. By replacing elided with implicit readability of the application might be improved.
2023-05-23 11:54:01 +00:00
Jarrett
33f81d0610
Update rustc and cargo version information in running-locally.md (#658)
Also improves verbiage of a sentence, from "With this is in place, then follow..." to "With this in place, follow..."
2023-05-23 09:43:57 +00:00
Bryan Hitchcock
584e3ecd7d
Fix inconsistent code in unbounded.md (#656)
Update unbounded.md to address inconsistent code

Fix inconsistency between concurrency `unbounded.md` and `bounded.md` by using implicitly named arguments for both.
2023-05-23 11:36:58 +02:00
Victor Costan
032c7e3b6b
Fix typo in basic/syntax-static-and-const.md (#650)
Fix typo in basic/syntax-static-and-const.md.
2023-05-22 09:36:52 +01:00
Martin Geisler
f02facd56d
Add missing newlines around <details> (#647)
The newlines makes the text more uniform when extracted into the POT
file (spotted while doing #646).
2023-05-19 09:43:44 -04:00
rbehjati
83663daaa2
Add the description of the chat-app exercise (#641)
* Adds a description of the async chat exercise
* Simplifies the use of Error in chat-async
* Links the solution to the async chat exercise
* Removes the elevator exercise
2023-05-17 18:22:11 +01:00
Edward Liaw
8406697449
Add code for speaker notes in trait inheritance (#643)
Give code samples of trait inheritance and a blanket implementation.

Signed-off-by: Edward Liaw <edliaw@google.com>
2023-05-17 09:02:02 +00:00
Dustin J. Mitchell
caeabdae3e
Beginnings of an async chat exercise (#627)
* beginnings of an async chat exercise

* really basic solution

* format
2023-05-16 15:51:01 +00:00
Diogo Anderson
a788680d5e
Fixing a typo in a "details" close tag (#638) 2023-05-15 22:20:54 +00:00
Martin Geisler
490b20e245
Link badges to the main branch (#636)
This is the only branch for which there is any expectation of
stability, so it makes sense to send people here.
2023-05-15 18:12:10 -04:00
Martin Geisler
0036843f0c
Fix typo in dining-philosophers-async.md (#631) 2023-05-12 14:34:11 +02:00
Martin Geisler
9c6bb081d4
Update "Running the course" based on latest experience (#628) 2023-05-11 17:23:01 +00:00
rbehjati
11571d0d1a
Add dining philosophers as an async exercise (#624)
* Adds dining philosophers as an async exercise
* Adds a solution for async dining philosophers
* Adds a solution page for the afternoon session on concurrency
2023-05-09 17:34:47 +01:00
Carlos Jimenez
ce7c5fdf22
Fix mistakes in book-library.rs (#619)
---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-05-08 08:20:42 +00:00
Bradford Hovinen
5bbb68be2c
Add a file which references some useful crates to use for writing tests (#617)
* Add a slide referencing recommended testing crates

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-05-05 14:59:25 +00:00
Andrew Walbran
5a495a508e
Update Cargo.lock. (#614)
This was missed in #583.
2023-05-05 11:25:45 +01:00
Tanuj
d83d1f1c48
Fix pluralisation inconsistency (#612) 2023-05-05 09:57:44 +02:00
Dustin J. Mitchell
d0bf0d7a44
Order Send/Sync before Arc/Mutex (#605)
The Arc/Mutex chapters mention Send/Sync in the speaker notes, and in
fact serve as good illustrations of the traits, so let's define the
traits before referencing them.
2023-05-05 09:50:17 +02:00
Andrew Walbran
9cff14ca31
Link arm-gic to main documentation page rather than crate page (#610) 2023-05-04 14:42:08 +00:00
Andrew Walbran
226aa21f3c
Use hyphen rather than underscore for gic-version (#611)
Older versions of QEMU seem to only accept a hyphen, while new versions accept either.
2023-05-04 15:41:15 +01:00
Andrew Walbran
93c1c814c3
Improve phrasing of comment (#609)
Some people interpreted the previous comment as meaning the RTC itself needed to be initialised or started somehow, but this is not the case.
2023-05-04 15:08:44 +01:00
Dustin J. Mitchell
cce3fff0d0
Minor fixes to async notes (#607)
* `join!( .., time::sleep(..))` isn't really a "timeout"

* Remove suggestion to make `sleep` take `&mut self`

I'm not sure what doing so demonstrates.

* Update src/async/control-flow/join.md

Co-authored-by: rbehjati <razieh@google.com>

---------

Co-authored-by: rbehjati <razieh@google.com>
2023-05-04 11:59:19 +00:00
Dustin J. Mitchell
1288d11adb
Fix title of 'Runtimes' (#606) 2023-05-04 07:56:43 -04:00
Martin Geisler
3b07b4768a
Add unit tests to Safe FFI exercise (#588) 2023-05-04 12:20:47 +02:00
Dustin J. Mitchell
09c996ad96
Move closures to the top level (#604)
move closures to the top level
2023-05-03 09:30:13 -04:00
Martin Geisler
841359f5df
Simplify methods slide (#594)
This tightens the language slightly. I also added a speaker note with
suggestions for more methods to add (if there is time).
2023-05-03 12:01:21 +02:00
Martin Geisler
789abc1028
Wrap comments at 80 columns (#592)
When teaching the class, I notice that these comments (which are
wrapped at 100 columns) cause a horizontal scrollbar which makes them
hard to read at a glance.

Here I wrapped them at 80 columns, which fits on the screen and which
avoids overly long lines.
2023-05-03 12:00:58 +02:00
Martin Geisler
4a09d053ac
Simplify fizz buzz slide (#595)
There is no need to introduce `match` here where we don’t have time to
talk about it in detail.
2023-05-03 09:56:58 +02:00
Martin Geisler
3b21053ff2
Cleanup references to "Day 4" (#603)
* Align outline with new spin-off course structure

With the new structure, the section on Android is a spin-off course
from the main 3-day course on Rust Fundamentals. The Bare-metal and
Concurrency days are spin-off courses in the same way.

* Explain new course structure

* Align Bare-Metal welcome page with other deep dives

* Merge Day 4 page into Course Structure page

* Remove Day 4 Welcome page

This aligns the Concurrency in Rust section with the Bare-Metal Rust
deep dive.

* Show subsections for Android deep dive

This aligns the Rust in Android section with the other deep dives.

* Clean up welcome page and README

We now cover async Rust and the course is no longer a four day course.

* Remove reference to the old Day 4

* Remove Day 4 references from exercises
2023-05-02 08:02:28 +02:00
Martin Geisler
c67922ce8c
Cleanup control flow slides (#587)
* Cleanup control flow slides

This avoids calling all the looping constructs “expressions” since
they all (except for `loop`) return trivial values.

---------

Co-authored-by: Dustin J. Mitchell <djmitche@google.com>
2023-04-29 03:12:24 +00:00
Martin Geisler
244e5b99c6
Provide more instructions in the library exercise (#589) 2023-04-29 05:11:12 +02:00
Martin Geisler
fc68829e14
Improve language around ownership of OsString (#602)
Based on discussion in #598.
2023-04-28 10:00:07 +02:00
Martin Geisler
b051b04afa
Use explicit Arc::clone instead of calling .clone() method (#596)
This is to highlight that the clones are cheap: they run custom logic
in the reference counted type, they don’t do a deep clone.
2023-04-27 23:46:09 +02:00
Martin Geisler
6ade739651
Ensure code blocks are editable (#597)
We should default to making code blocks editable: this ensures
consistent syntax highlighting (see #343) and it allows the instructor
to freely edit anything they want.
2023-04-27 23:45:41 +02:00
Martin Geisler
5074b1751c
Hint at the list of conversions in FFI exercise (#598)
I see people struggle a lot with guessing why they need to convert
between all these types. The explanations here should help with that.
2023-04-27 23:45:15 +02:00
Martin Geisler
f895ffc5a8
Remove exotic string types from scalar type slide (#593)
When teaching the class, I’ve noticed that raw strings and byte
strings tend to cause confusion. The slide is meant to be a friendly
introduction and show how Rust is similar to other languages like C
and C++. Instead, the string types cause a ton of questions which are
unnecessary at this early point.

The information is still there, but now in the form of a speaker note.
2023-04-27 19:57:07 +02:00
Martin Geisler
c0d03bd86b
Consistently use err for the error value (#599) 2023-04-27 19:10:49 +02:00
Andrew Walbran
9d4a34c501
Use smccc crate rather than psci in examples and exercise. (#583)
It was renamed.
2023-04-27 10:54:48 +01:00
John Scheible
c5d15edad4
Direct users to "smccc" crate rather than "psci" (#578)
psci's docs.rs page redirects users to `smccc` instead as the crate has been renamed.
2023-04-26 17:06:28 +01:00
Eric Ye
9187bf0b5e
Add some more hints to the bare-metal RTC exercise (#581)
* Add some more hints to the bare-metal RTC exercise

I and several others had some difficulties with this part of the problem, especially with regards to knowing where the RTC was wired up and how to fully enable the GIC / interrupts, so add this information to the exercise.

* Remove extra semicolon.

---------

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-04-25 09:46:37 +01:00
Dustin J. Mitchell
69a62ba227
Add a bit about 'use' (#580)
* Add a bit about 'use'

* fix paths
2023-04-24 18:51:23 +00:00
Dustin J. Mitchell
6744822454
Minor fixes (#579)
* order the Cat and Dog correctly in the vec

* make example editable

* patterns: capture vs. constant

* clarify notes on indexing a string
2023-04-24 14:46:38 -04:00
Andrew Walbran
4266078684
Add pkg-config to list of packages (#575)
pkg-config is also required for the cargo install to work.
2023-04-21 20:29:18 +02:00
Matt Schulte
6a61829d85
Fix safe FFI exercise on macOS (#572)
* Fix safe FFI exercise on macOS

Use the macOS definition of dirent.

Fixes #570

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-04-21 03:10:12 +02:00
jaewan-github
e371fd7e54
Main - Fix bug in exercise solution (#569)
* Fix bug in the exercise solution

Window may be nested, so its width should also consider border size.
2023-04-20 18:04:33 +02:00
Andrew Walbran
c5863f6642
Add optional extension to RTC exercise (#562)
* Add methods to mask and clear interrupts.

* Start on GICv3 driver.

* Enable and use RTC interrupt.

* WFI

* Add newtype for interrupt ID.

* Add extension to use interrupt.

* Add method to send an SGI.

* Silence warnings about unused methods in provided drivers.

* Implement Debug manually for IntId.

It's useful to say what kind of interrupt it is.

* Acknowledge and log interrupt.

We should end it as well, but doing so results in a loop unless we first
clear the match.

* cargo fmt with imports_granularity = "module"

* Use arm-gic crate rather than including driver in the example.
2023-04-17 15:38:51 +01:00
Dustin J. Mitchell
d143528e07
Minor fix-ups to the async section. (#566)
These address some comments in #496.
2023-04-16 19:20:24 -04:00
Andrew Walbran
87f1976589
cargo fmt with imports_granularity = "module" (#564) 2023-04-16 20:57:59 +02:00
Dustin J. Mitchell
0d30da7f23
Add an "async" session (#496)
* beginning of an Async section

* address review comments

* Add futures page (#497)

NOTE: `mdbook test` does not allow code samples to reference other crates, so
they must be marked as `compile_fail`; see #175.

* Add Runtimes & Tasks (#522)

These concepts are closely related, and there's not much else to know
about runtimes other than "they exist".

This removes the bit about futures being "inert" because it doesn't
really lead anywhere.

* Async chapter (#524)

* Add async channels chapter

* Async control flow

* Async pitfalls

* Separate in multiple chapters + add daemon section

* Merge reentering threads in blocking-executor

* async_trait

* Async fixes (#546)

* Async: some ideas for simplifying the content (#550)

* Simplify the async-await slide
* Shorten futures and move it up
* Add a page on Tokio

* Modifications to the async section (#556)

* Modifications to the async section

* Remove the "Daemon" slide, as it largely duplicates the "Tasks" slide.
  The introduction to the "Control Flow" section mentions tasks as a
  kind of control flow.

* Reorganize the structure in SUMMARY.md to correspond to the directory
  structure.

* Simplify the "Pin" and "Blocking the Executor" slides with steps in
  the speaker notes to demonstrate / fix the issues.

* Rename "join_all" to "Join".

* Simplify some code samples to shorten them, and to print output rather
  than asserting.

* Clarify speaker notes and include more "Try.." suggestions.

* Be consistent about where `async` blocks are introduced (in the
  "Tasks" slide).

* Explain `join` and `select` in prose.

* Fix formatting of section-header slides.

* Add a note on async trait (#558)

---------

Co-authored-by: sakex <alexandre@senges.ch>
Co-authored-by: rbehjati <razieh@google.com>
2023-04-14 14:06:50 +00:00
Dustin J. Mitchell
6c97e1a7be
Add a new async exercise: elevator simulation. (#557) 2023-04-13 16:26:57 +02:00
Andrew Walbran
d8e442b9cb
Extend bare metal afternoon exercise (#561)
* Add methods to set match register and check whether it matches.

* Add first extension to RTC exercise, using match register.

* No need for constants to be public.
2023-04-13 10:58:06 +01:00
Martin Geisler
5b316b8b5b Prevent accidental publishing the link-checker exercise 2023-04-11 10:47:18 +01:00
Andrew Walbran
bf18b33e39 Use exerciser for day 4 exercises too. 2023-04-11 10:47:18 +01:00
Yuri Astrakhan
5cdb73387f
Inline format vars to make the format str simpler (#551) 2023-04-06 12:00:10 +02:00
Andrew Walbran
86d8c4ae54 Rename exercise template directory and archive. 2023-04-05 16:28:07 +01:00
Andrew Walbran
9375126b3c Use comment rather than inline code to find filename. 2023-04-05 16:28:07 +01:00