Going through rustlings for the first time
at main 736 B view raw
1// You can bring module paths into scopes and provide new names for them with 2// the `use` and `as` keywords. 3 4mod delicious_snacks { 5 // TODO: Add the following two `use` statements after fixing them. 6 // use self::fruits::PEAR as ???; 7 // use self::veggies::CUCUMBER as ???; 8 pub use self::fruits::PEAR as fruit; 9 pub use self::veggies::CUCUMBER as veggie; 10 11 mod fruits { 12 pub const PEAR: &str = "Pear"; 13 pub const APPLE: &str = "Apple"; 14 } 15 16 mod veggies { 17 pub const CUCUMBER: &str = "Cucumber"; 18 pub const CARROT: &str = "Carrot"; 19 } 20} 21 22fn main() { 23 println!( 24 "favorite snacks: {} and {}", 25 delicious_snacks::fruit, 26 delicious_snacks::veggie, 27 ); 28}