1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-09-20 12:22:35 +02:00
rustlings/exercises/10_modules/modules2.rs

28 lines
668 B
Rust
Raw Normal View History

// You can bring module paths into scopes and provide new names for them with
2024-06-22 13:24:06 +02:00
// the `use` and `as` keywords.
2024-07-04 13:38:35 +02:00
#[allow(dead_code)]
mod delicious_snacks {
2024-06-26 02:26:04 +02:00
// TODO: Add the following two `use` statements after fixing them.
2024-06-22 13:24:06 +02:00
// use self::fruits::PEAR as ???;
// use self::veggies::CUCUMBER as ???;
2019-01-23 21:56:05 +01:00
mod fruits {
2024-06-22 13:24:06 +02:00
pub const PEAR: &str = "Pear";
pub const APPLE: &str = "Apple";
}
2019-01-23 21:56:05 +01:00
mod veggies {
2024-06-22 13:24:06 +02:00
pub const CUCUMBER: &str = "Cucumber";
pub const CARROT: &str = "Carrot";
}
}
fn main() {
println!(
"favorite snacks: {} and {}",
delicious_snacks::fruit,
2024-06-22 13:24:06 +02:00
delicious_snacks::veggie,
);
}