From 47bc98784bb0ce0c0a76f64a718775a245cec0f4 Mon Sep 17 00:00:00 2001 From: Kivanc Gunalp Date: Sun, 26 Jul 2026 15:09:07 +0000 Subject: [PATCH] Register file_io exercises in build config Adds file_io1-3 (and their solutions) to dev/Cargo.toml's bin list so 'cargo dev check'/'cargo dev update' pick them up, and registers them in rustlings-macros/info.toml with hints that explain each exercise's learning goal and point at the relevant std API. --- dev/Cargo.toml | 6 ++++++ rustlings-macros/info.toml | 42 +++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/dev/Cargo.toml b/dev/Cargo.toml index 66bc1dfe..ee5f60fd 100644 --- a/dev/Cargo.toml +++ b/dev/Cargo.toml @@ -188,6 +188,12 @@ bin = [ { name = "conversions4_sol", path = "../solutions/23_conversions/conversions4.rs" }, { name = "conversions5", path = "../exercises/23_conversions/conversions5.rs" }, { name = "conversions5_sol", path = "../solutions/23_conversions/conversions5.rs" }, + { name = "file_io1", path = "../exercises/24_file_io/file_io1.rs" }, + { name = "file_io1_sol", path = "../solutions/24_file_io/file_io1.rs" }, + { name = "file_io2", path = "../exercises/24_file_io/file_io2.rs" }, + { name = "file_io2_sol", path = "../solutions/24_file_io/file_io2.rs" }, + { name = "file_io3", path = "../exercises/24_file_io/file_io3.rs" }, + { name = "file_io3_sol", path = "../solutions/24_file_io/file_io3.rs" }, ] [package] diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml index 3a1cac35..66725390 100644 --- a/rustlings-macros/info.toml +++ b/rustlings-macros/info.toml @@ -304,7 +304,7 @@ Now, you have another tool in your toolbox!""" name = "vecs1" dir = "05_vecs" hint = """ -In Rust, there are two basic ways to define a Vector. +In Rust, there are two ways to define a Vector. 1. One way is to use the `Vec::new()` function to create a new vector and fill it with the `push()` method. 2. The second way is to use the `vec![]` macro and define your elements @@ -1211,3 +1211,43 @@ name = "conversions5" dir = "23_conversions" hint = """ Add `AsRef` or `AsMut` as a trait bound to the functions.""" + +# File IO Exercises + +[[exercises]] +name = "file_io1" +dir = "24_file_io" +test = false +hint = """ +Learning goal: read a whole file into memory and handle the Result it +produces, rather than unwrapping it. + +`fs::read_to_string` returns a `Result`. Match on +it (or use `?`) to get the file's contents out of the `Ok` variant, and +compare that to the text that `create_required_files` wrote to the file. +""" + +[[exercises]] +name = "file_io2" +dir = "24_file_io" +test = false +hint = """ +Learning goal: read a file efficiently, line by line, using a BufReader, +and understand why buffering matters for I/O performance. + +`BufReader::new(input_file)` wraps a `File` so you can call `.lines()` on +it, which yields each line as a `Result`. +""" + +[[exercises]] +name = "file_io3" +dir = "24_file_io" +test = false +hint = """ +Learning goal: build a filesystem path with PathBuf and inspect the file +it points to without hardcoding platform-specific path separators. + +`Path`/`PathBuf` expose a `.metadata()` method that returns a +`Result`, giving you access to creation time, +size (`.len()`), and permissions. +"""