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.
Official Rustlings solutions
Before you finish an exercise, its solution file will only contain an empty main function.
The content of this file will be automatically replaced by the actual solution once you finish the exercise.
Note that these solutions are often only one possibility to solve an exercise.