1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-21 22:49:44 +02:00

217 Commits

Author SHA1 Message Date
Varun Somani
3813d0b6f1
Add test case for invalid non digit cc number ()
Adding this test case to handle case where we have non-numeric cc number
along with a valid cc number. This is discovered when we filter with
is_numeric() instead of !is_whitespace() all test case does pass. To
handle such scenario adding this test case.
2023-09-07 08:30:18 +00:00
Antonio Linhart
11087c8411
Add typos to CI ()
Hi all!

This CL fixes :
* Avoids including current false-positives in the checking of typos
* Excludes localization-related files, as `typos` works with
  English words
* Fixes existing typos caught in the repo

Tested this in CI with a typo and it showed up in the list of actions!

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-09-05 20:21:59 +00:00
Frances Wingerter
890c46a90c
Fix some exercise location mixups in Day 2 ()
Should supersede , I think.
2023-08-28 18:53:22 +00:00
Frances Wingerter
d3a90373b0
Reorder material on first two days ()
- Morning of Day 1 still introduces the language and its high-level
goals/value proposition, and starts with the built-in data types Rust
provides, and how you define a function. 
- Afternoon of Day 1 gets a front loading of the basic control flow
structures in Rust but not the more exotic ones.
- The exercises for day 1 afternoon will be the Luhn algorithm (where we
can match on digits and enums such as `Option`.
- Morning of day 2 still has discussion of memory management.

Fixes .

---------

Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-08-25 17:42:31 +02:00
Danny Yoo
40b9a1fc2c
Update for-loops.md to remove misleading sentence ()
Drops the comment about usage in the other loop. It's not related to the
focus on copy semantics, and so we want to eliminate that possible
confusion.

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-08-23 14:10:24 +00:00
Danny Yoo
25d4281992
Iterate over array ref instead of array. ()
This revises the example to iterate over `&array` to dodge a few issues.
2023-08-15 12:50:18 +00:00
Dustin J. Mitchell
e596b80c03
Tweaks from student feedback ()
* help students with the luhn exercise

* mention method-specific types in speaker notes

* Update src/exercises/day-2/luhn.md

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

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-08-11 12:40:05 +00:00
Martin Geisler
c7240f604f
Expand "iff" to "if and only if" in pl031.rs ()
* Expand "if" to "if and only if" in pl031.rs

Similar to .
2023-08-04 11:04:02 +01:00
Martin Geisler
3c7659d59b
Align dining-philosophers-async.rs with sync version ()
* Align dining-philosophers-async.rs with sync version

This updates the version to use `std::mem::swap` like the synchronous version.

* Apply suggestions from code review
2023-07-25 06:56:27 +00:00
Martin Geisler
e8ea741cea
Use Arc::clone instead of .clone() ()
The fully qualified syntax is recommended for `Arc` which implements all methods as associated methods.
2023-07-24 11:19:06 -07:00
Victor Costan
ef99d15529
Fix solution in Link Checker in Concurrency Morning exercises ()
* Fix solution in Link Checker in Concurrency Morning exercises.

This change fixes the following issues with the current solution:

1. It is not listed on the "solutions" page.
2. It is not multi-threaded and does not use channels.

---------

Co-authored-by: Dustin J. Mitchell <djmitche@google.com>
2023-07-13 10:52:06 +02:00
Frances Wingerter
2f5dcbafc3
Rework health statistics exercise ()
* exercises: health-statistics: weight -> height

weight may be a sensitive topic for some readers; use height instead as this isn't important to the content of the course

* exercises: health-statistics: add health report

this lets us see a non-setter use case for &mut self

it also makes the 'statistics' side of this exercise more explicit as we count doctor visits

* exercises: health-statistics: normalize variable names
2023-07-11 18:01:49 -04:00
Sharun
f5764ad4bc
remove $ from code-blocks in other markdown files as well ()
* remove $ from code blocks in translations

* remove $ from code blocks in the other markdown files as well

* Revert "remove $ from code blocks in the other markdown files as well"

This reverts commit eda922dab93dd2d2967581650a5c983432ec3a80.

* remove $ from code blocks in setup.md

* re-added the previous changes

* revert logging.md
2023-07-10 21:25:41 -07:00
Erdem
427aab110f
Adds a comment for an iterator based implementation for Polygon::length ()
Outlines an alternative implementation for Polygon::length.  This exercise is aimed at novice users and we want to keep the implementation simple. For users familiar with iterator concepts this comment points to an alternative.
2023-07-10 22:55:33 +00:00
Dustin J. Mitchell
88510e9e72
fix links for IntoIterator for Vec () 2023-07-07 09:27:35 -04:00
Frances Wingerter
7f03a67a6a
Rename 'designing a library' example ()
rename 'designing a library' example

library design in Rust is its own topic that this course does not cover; to avoid confusion, let's stick to describing things in terms of books
2023-07-06 08:40:47 +00:00
Victor Costan
6df4ba24dd
Clarify that each philosopher should think/eat 100 times ()
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 ()
* 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
Victor Costan
0c867c952f
"Strings and Iterators" solution that uses let-else ()
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 ()
* 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 ()
Unified FFI setup for for readdir() on macOS.
2023-06-23 15:48:18 +02:00
Martin Geisler
186d333227
Run builds on both Mac OS and Linux ()
* Run builds on both Mac OS and Linux

This would have helped us catch .

* Fix MacOS CI ()

* 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
Mauve
4b7b5d83ea
Make chat-client reads cancellation safe ()
* Make chat-client reads cancellation safe

* Update chat-app references
2023-06-09 16:35:52 +02:00
rbehjati
83663daaa2
Add the description of the chat-app exercise ()
* 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
Dustin J. Mitchell
caeabdae3e
Beginnings of an async chat exercise ()
* beginnings of an async chat exercise

* really basic solution

* format
2023-05-16 15:51:01 +00:00
Martin Geisler
0036843f0c
Fix typo in dining-philosophers-async.md () 2023-05-12 14:34:11 +02:00
rbehjati
11571d0d1a
Add dining philosophers as an async exercise ()
* 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 ()
---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-05-08 08:20:42 +00:00
Andrew Walbran
5a495a508e
Update Cargo.lock. ()
This was missed in .
2023-05-05 11:25:45 +01:00
Andrew Walbran
9cff14ca31
Link arm-gic to main documentation page rather than crate page () 2023-05-04 14:42:08 +00:00
Andrew Walbran
226aa21f3c
Use hyphen rather than underscore for gic-version ()
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 ()
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
Martin Geisler
3b07b4768a
Add unit tests to Safe FFI exercise () 2023-05-04 12:20:47 +02:00
Martin Geisler
3b21053ff2
Cleanup references to "Day 4" ()
* 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
244e5b99c6
Provide more instructions in the library exercise () 2023-04-29 05:11:12 +02:00
Martin Geisler
fc68829e14
Improve language around ownership of OsString ()
Based on discussion in .
2023-04-28 10:00:07 +02:00
Martin Geisler
5074b1751c
Hint at the list of conversions in FFI exercise ()
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
Andrew Walbran
9d4a34c501
Use smccc crate rather than psci in examples and exercise. ()
It was renamed.
2023-04-27 10:54:48 +01:00
Eric Ye
9187bf0b5e
Add some more hints to the bare-metal RTC exercise ()
* 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
Matt Schulte
6a61829d85
Fix safe FFI exercise on macOS ()
* Fix safe FFI exercise on macOS

Use the macOS definition of dirent.

Fixes 

---------

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 ()
* 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 ()
* 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. ()
These address some comments in .
2023-04-16 19:20:24 -04:00
Andrew Walbran
87f1976589
cargo fmt with imports_granularity = "module" () 2023-04-16 20:57:59 +02:00
Dustin J. Mitchell
0d30da7f23
Add an "async" session ()
* beginning of an Async section

* address review comments

* Add futures page ()

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

* Add Runtimes & Tasks ()

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 ()

* 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 ()

* Async: some ideas for simplifying the content ()

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

* Modifications to the async section ()

* 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 ()

---------

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. () 2023-04-13 16:26:57 +02:00
Andrew Walbran
d8e442b9cb
Extend bare metal afternoon exercise ()
* 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 () 2023-04-06 12:00:10 +02:00