mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-08-14 14:26:56 +00:00
- file_io2: replace the manual line_number counter with .lines().enumerate(), and replace buffered_file_writer.write(format!(...).as_bytes()) with writeln!, which both formats and guarantees a complete write (write_fmt loops internally, unlike a single Write::write call). - file_io3: replace the manual match on file_path.parent() with .ok_or_else(...)? for a more idiomatic Option-to-Result conversion. Verified locally: both solutions compile under edition 2024, clippy is silent, and running them still produces identical output (3 lines processed / 117-byte file, non-readonly permissions) with no leftover files.
Exercise to Book Chapter mapping
| Exercise | Book Chapter |
|---|---|
| variables | §3.1 |
| functions | §3.3 |
| if | §3.5 |
| primitive_types | §3.2, §4.3 |
| vecs | §8.1 |
| move_semantics | §4.1-2 |
| structs | §5.1, §5.3 |
| enums | §6, §19.3 |
| strings | §8.2 |
| modules | §7 |
| hashmaps | §8.3 |
| options | §10.1 |
| error_handling | §9 |
| generics | §10 |
| traits | §10.2 |
| lifetimes | §10.3 |
| tests | §11.1 |
| iterators | §13.2-4 |
| smart_pointers | §15, §16.3 |
| threads | §16.1-3 |
| macros | §20.5 |
| clippy | Appendix D |
| conversions | n/a |