rustlings

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

modules2.rs (532B)


      1 mod delicious_snacks {
      2     // Added `pub` and used the expected alias after `as`.
      3     pub use self::fruits::PEAR as fruit;
      4     pub use self::veggies::CUCUMBER as veggie;
      5 
      6     mod fruits {
      7         pub const PEAR: &str = "Pear";
      8         pub const APPLE: &str = "Apple";
      9     }
     10 
     11     mod veggies {
     12         pub const CUCUMBER: &str = "Cucumber";
     13         pub const CARROT: &str = "Carrot";
     14     }
     15 }
     16 
     17 fn main() {
     18     println!(
     19         "favorite snacks: {} and {}",
     20         delicious_snacks::fruit,
     21         delicious_snacks::veggie,
     22     );
     23 }