mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-28 06:49:19 +00:00
feat: add exercise modules in diferent files/dirs
closes: https://github.com/rust-lang/rustlings/issues/1143
This commit is contained in:
parent
63e0fab85e
commit
42b924aeab
@ -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" },
|
||||
|
||||
3
exercises/09_modules/fruit.rs
Normal file
3
exercises/09_modules/fruit.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn get_fav_fruit() {
|
||||
println("Got your favourite fruit!")
|
||||
}
|
||||
5
exercises/09_modules/modules4.rs
Normal file
5
exercises/09_modules/modules4.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// TODO: fix the compiler error for missing modules.
|
||||
|
||||
fn main() {
|
||||
fruit::get_fav_fruit();
|
||||
}
|
||||
@ -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]]
|
||||
|
||||
3
solutions/09_modules/fruit.rs
Normal file
3
solutions/09_modules/fruit.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn get_fav_fruit() {
|
||||
println("Got your favourite fruit!")
|
||||
}
|
||||
5
solutions/09_modules/modules4.rs
Normal file
5
solutions/09_modules/modules4.rs
Normal file
@ -0,0 +1,5 @@
|
||||
mod fruit;
|
||||
|
||||
fn main() {
|
||||
fruit::get_fav_fruit();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user