rustlings

solving rustlings ft. dracuxan
git clone [email protected]:dracuxan/rustlings.git
Log | Files | Refs

modules2.rs (655B)


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