feat: add exercise modules in diferent files/dirs

closes: https://github.com/rust-lang/rustlings/issues/1143
This commit is contained in:
eveeifyeve 2025-10-05 21:37:09 +11:00
parent 63e0fab85e
commit 42b924aeab
6 changed files with 30 additions and 0 deletions

View File

@ -86,6 +86,8 @@ bin = [
{ name = "modules2_sol", path = "../solutions/09_modules/modules2.rs" },
{ name = "modules3", path = "../exercises/09_modules/modules3.rs" },
{ name = "modules3_sol", path = "../solutions/09_modules/modules3.rs" },
{ name = "modules4", path = "../exercises/09_modules/modules4.rs" },
{ name = "modules4_sol", path = "../solutions/09_modules/modules4.rs" },
{ name = "hashmaps1", path = "../exercises/11_hashmaps/hashmaps1.rs" },
{ name = "hashmaps1_sol", path = "../solutions/11_hashmaps/hashmaps1.rs" },
{ name = "hashmaps2", path = "../exercises/11_hashmaps/hashmaps2.rs" },

View File

@ -0,0 +1,3 @@
pub fn get_fav_fruit() {
println("Got your favourite fruit!")
}

View File

@ -0,0 +1,5 @@
// TODO: fix the compiler error for missing modules.
fn main() {
fruit::get_fav_fruit();
}

View File

@ -544,6 +544,18 @@ hint = """
`use` statement for these two to bring them into scope. You can use nested
paths to bring these two in using only one line."""
[[exercises]]
name = "modules4"
dir = "09_modules"
test = false
hint = """
The mod.rs is trying to use the modules from the file cake.rs and fruit directory.
Complete the `mod` statements to fit the use in `main`.
Learn more in The Book:
https://doc.rust-lang.org/book/ch07-05-separating-modules-into-different-files.html
"""
# HASHMAPS
[[exercises]]

View File

@ -0,0 +1,3 @@
pub fn get_fav_fruit() {
println("Got your favourite fruit!")
}

View File

@ -0,0 +1,5 @@
mod fruit;
fn main() {
fruit::get_fav_fruit();
}