rustlings/exercises/10_modules/modules2.rs

27 lines
647 B
Rust
Raw Normal View History

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