mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-05 08:25:26 +02:00
Tweaks from student feedback (#1061)
* 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>
This commit is contained in:
parent
8956fab9bb
commit
e596b80c03
@ -6,8 +6,8 @@ following to validate the credit card number:
|
||||
|
||||
* Ignore all spaces. Reject number with less than two digits.
|
||||
|
||||
* Moving from right to left, double every second digit: for the number `1234`,
|
||||
we double `3` and `1`.
|
||||
* Moving from **right to left**, double every second digit: for the number `1234`,
|
||||
we double `3` and `1`. For the number `98765`, we double `6` and `8`.
|
||||
|
||||
* After doubling a digit, sum the digits. So doubling `7` becomes `14` which
|
||||
becomes `5`.
|
||||
@ -16,8 +16,10 @@ following to validate the credit card number:
|
||||
|
||||
* The credit card number is valid if the sum ends with `0`.
|
||||
|
||||
Copy the following code to <https://play.rust-lang.org/> and implement the
|
||||
function:
|
||||
Copy the code below to <https://play.rust-lang.org/> and implement the function.
|
||||
|
||||
Try to solve the problem the "simple" way first, using `for` loops and integers.
|
||||
Then, revisit the solution and try to implement it with iterators.
|
||||
|
||||
|
||||
```rust
|
||||
|
@ -61,6 +61,8 @@ fn main() {
|
||||
but it can lead into complications with the borrow checker.
|
||||
* Try removing `to_string()` from the example above and see if it still compiles. Where do you think we might run into issues?
|
||||
|
||||
* This type has several "method-specific" return types, such as `std::collections::hash_map::Keys`. These types often appear in searches of the Rust docs. Show students the docs for this type, and the helpful link back to the `keys` method.
|
||||
|
||||
[1]: https://doc.rust-lang.org/std/collections/hash_map/struct.HashMap.html#impl-From%3C%5B(K,+V);+N%5D%3E-for-HashMap%3CK,+V,+RandomState%3E
|
||||
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user