1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-06-15 00:04:58 +02:00
Commit Graph

247 Commits

Author SHA1 Message Date
f2650de369 fix(clippy1): Updated code to test correctness clippy lint with approx_constant lint rule
closes #888
2021-12-15 11:46:27 -05:00
d1ee2daf14 fix(structs3.rs): assigned value to cents_per_gram in test
Intended to simplify the lesson by removing the need to figure out what the value is meant to be based on the tests.

Previous commits (9ca08b8f2b and 114b54cbdb (diff-ce1c232ff0ddaff909351bb84cb5bff423b5b9e04f21fd4db7ffe443e598e174)) removed the mathematical complexity, and I feel this addition is a needed change to further streamline the exercise.
2021-10-30 16:55:58 -06:00
1663a16ead fix(traits1): rename test functions to snake case (#854)
Co-authored-by: zhangshaozhi <zhangshaozhi@ZhangshaozhideMacBook-Pro.local>
2021-10-18 13:57:12 +02:00
46c28d5cef fix(move_semantics5): correct typo (#857) 2021-09-30 10:18:36 +02:00
bf33829da2 fix(structs3): remove redundant 'return' (#852) 2021-09-27 10:03:28 +02:00
c2ed98deb3 Merge pull request #781 from tlyu/advanced-errs
feature: advanced errors
2021-09-25 11:18:55 +02:00
abd6b70c72 feat: add advanced_errs2
New exercise to demonstrate traits that make it easier for other code
to consume our custom error types.
2021-09-25 11:18:23 +02:00
882d535ba8 feat: add advanced_errs1
New section and exercise to demonstrate the `From` trait for errors
and its usefulness with the `?` operator.
2021-09-25 11:18:21 +02:00
d75759e829 fix(move_semantics5): change &mut *y to &mut x (#814)
Instead of having to explain why 
```rs
let mut x = 100; 
let y = &mut x;
let mut z_owned = *y;
let z = &mut z_owned;
*y += 100;
*z += 1000;
```
and 
```rs
let mut x = 100; 
let y = &mut x;
let z = &mut *y;
*y += 100;
*z += 1000;
```
are different, you still get the point across about having only one mutable reference.
As it stands, this exercise does too much (dereferencing and having only one mutable reference), and by doing so confuses people.

Example of someone being confused by this:
<https://discord.com/channels/273534239310479360/273541522815713281/872689531428692040>
2021-09-25 10:52:18 +02:00
0a11bad714 feat(quiz1): add default function name in comment (#838) 2021-09-21 10:43:44 +02:00
1c3beb0a59 fix(modules2): fix typo (#835) 2021-09-06 16:32:39 +02:00
dfd2fab4f3 feat(modules): update exercises, add modules3 (#822)
Co-authored-by: diannasoriel <mokou@fastmail.com>
2021-09-03 10:41:12 +02:00
96fc301764 chore(quiz1): revert wording 2021-08-26 10:30:18 +02:00
03131a3d35 fix(quiz1): Fix inconsistent wording (#826)
The second test expects the function to return 80 when there is an order of 40 apples, but the current wording implies returning 40 will pass as well
2021-08-24 10:48:51 +02:00
ana
df25684cb7 fix(move_semantics5): Clarify instructions 2021-07-29 12:37:15 +02:00
8e313cffaa Merge pull request #732 from apogeeoak/iterators5
chore(iterators5): Minor formatting improvements.
2021-07-09 12:24:42 +02:00
6948905716 Merge pull request #737 from ghost/correct-small-typo
Correct small typo in exercises/conversions/from_str.rs
2021-07-08 11:07:21 +02:00
d876649616 fix(quiz1): Updated question description (#794)
Co-authored-by: Rakshit Sinha <rakshit.sinha@oracle.com>
2021-07-07 22:18:33 +02:00
8774e47dc3 docs: Update collections README with HashMap link 2021-07-06 01:31:27 -07:00
e422ab1507 docs: Update exercise to chapter mapping for HashMap 2021-07-05 23:07:34 -07:00
2dc93cadda fix(from_str, try_from_into): custom error types
Remove the use of trait objects as errors from `from_str` and
`try_from_into`; they seem to have caused a lot of confusion in
practice. (Also, it's considered best practice to use custom error
types instead of boxed errors in library code.) Instead, use custom
error enums, and update hints accordingly. Hints also provide
some guidance about converting errors, which could be covered
more completely in a future advanced errors section.

Also move from_str to directly after the similar exercise `from_into`,
for the sake of familiarity when solving.
2021-06-24 21:33:41 -05:00
a3ea37b76e Merge pull request #771 from tlyu/iterators5-trait-tweak
fix(iterators5): derive Clone, Copy
2021-06-24 14:17:05 +02:00
ec63cadadb Merge pull request #772 from tlyu/errors-rework
feature: improve error_handling exercises
2021-06-24 14:12:34 +02:00
b7ddd09fab address review feedback
Adjust error text and naming to conform with best practices.
Use `map_err()` instead of `or()`. Wrap lower-level errors instead of
ignoring their details.

Also, don't "cheat" by bypassing the `new()` function in tests.

Fix a dangling reference in the try_from_into hints.
2021-06-09 23:27:53 -05:00
ZC
48ffcbd2c4 fix(variables5): confine the answer further
let mut number = 3; can lead to a correct answer, so the comment helps to direct the users to the intended answer.
2021-06-07 18:22:55 +08:00
68d3ac567c feature: improve error_handling exercises
Add new exercises errors5 and errors6, to introduce boxed errors and
custom error enums more gently. Delete errorsn, because it tried to do
too much too soon.
2021-06-06 23:08:57 -05:00
50ab289da6 fix: rename result1 to errors4
Also put it in the ERROR HANDLING section where it probably belongs.
2021-06-06 23:08:54 -05:00
91fc9e3118 fix(iterators5): derive Clone, Copy
To allow more flexibility in solutions, derive `Clone` and `Copy`
for `Progress`.
2021-06-06 17:38:02 -05:00
1b85828548 fix: move_semantics5 hints
Improve the hints for move_semantics5, as well as the explanatory
comments in the code.

Previously, it was not clear what possible changes were allowed.
It seems that reordering the statements might be the intended solution.
The previous comment about not "adding newlines" doesn't make sense,
so treating it as "adding new lines" makes it more clear.
2021-05-22 22:09:58 -05:00
399ab328d8 feat: Add move_semantics5 exercise. (#746)
* feat: Add move_semantics5 exercise.

* feat: Add option3 exercise

* Address review comments. Fix typos, sentence formatting.

* Remove unwanted newline.

* Address review comments: make comment inline, fix format in print.
2021-05-17 14:10:40 +02:00
4d4fa77459 fix: remove trailing whitespaces from iterators1 2021-05-12 10:20:07 -05:00
3145794084 fix: add hints to generics1 and generics2 exercises 2021-05-11 14:50:05 -05:00
d9b69bd1a0 fix: remove trailing whitespace 2021-05-09 17:58:54 -05:00
9569c9a9e7 style(standard_library_types): stray line break 2021-04-29 23:31:26 +02:00
86cc85295a fix: Correct small typo in exercises/conversions/from_str.rs 2021-04-27 21:11:40 +02:00
650b1dee54 chore: Update quiz1.rs add explicit test for 40 2021-04-25 19:02:50 +02:00
7f0d2c2bf0 chore(iterators5): Minor formatting improvements. 2021-04-24 12:42:06 -04:00
249ad44cc0 docs(exercises): updated all exercises readme files
all exercises readme files now have a unified structure and a description
2021-04-23 19:54:31 +02:00
54804e344d Merge pull request #721 from Zerotask/add-further-help-for-generics3
docs(generics): add bounds help
2021-04-23 15:05:00 +02:00
f253103a31 docs(generics): add bounds help
add help for bounds provided by the rust by example book
2021-04-22 22:11:04 +02:00
1120db57a6 docs(errors): add additional help for Result/Boxing
add additional help information provided by the rust by example book
2021-04-22 21:32:29 +02:00
81be404487 feat(arc1): Add more details to description and hint (#710)
Co-authored-by: bmacer <bmacer@cisco.com>
Co-authored-by: marisa <mokou@fastmail.com>
Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2021-04-21 14:50:03 +02:00
79cc657917 Merge pull request #646 from apogeeoak/iterator
Added iterators5.rs exercise.
2021-04-21 10:10:50 +02:00
9c88ea9126 Improved iterators5.rs explanation. 2021-04-20 18:55:04 -04:00
2b766ef9f9 Merge pull request #648 from apogeeoak/iterator2
Moved iterators2.rs errors out of tests.
2021-04-20 11:24:10 +02:00
bd3d9ac9d5 Merge pull request #649 from apogeeoak/iterator3
Enabled iterators3.rs to run without commented out tests.
2021-04-20 11:22:39 +02:00
6bd791f2f4 fix(structs): Add 5.3 to structs/README (#652)
Co-authored-by: Shao Yang Hong <shaoyang.hong@ninjavan.co>
2021-04-20 11:19:24 +02:00
b4de659438 fix(option2): Rename uninformative variables (#675)
Renaming uninformative names like `optional_value`, `value`, `optional_values_vec` and `value` helps users distinguish between the two parts of the task.
2021-04-20 11:18:05 +02:00
72aaa15e6a fix(hashmap2): Update incorrect assertion (#660)
The test description says "at least five types of fruit", but the test itself is checking for exactly five types of fruit, which was a bit misleading for newcomers like me :) 

A simple change from "==" to ">=" should do the trick and successfully check for the "at least" condition.
2021-04-20 11:15:49 +02:00
f2ad3a6a0b Merge pull request #697 from WowSuchRicky/main
Rename 'Lichi' to 'Lychee' in the fruit example
2021-04-13 10:40:07 -04:00