diff --git a/exercises/hashmaps/hashmaps1.rs b/exercises/hashmaps/hashmaps1.rs index 80829eaa..af3b954a 100644 --- a/exercises/hashmaps/hashmaps1.rs +++ b/exercises/hashmaps/hashmaps1.rs @@ -16,12 +16,15 @@ use std::collections::HashMap; fn fruit_basket() -> HashMap { - let mut basket = // TODO: declare your hash map here. + let mut basket = HashMap::new();// TODO: declare your hash map here. // Two bananas are already given for you :) basket.insert(String::from("banana"), 2); // TODO: Put more fruits in your basket here. + basket.insert(String::from("apple"), 1); + basket.insert(String::from("orange"), 3); + basket.insert(String::from("grapes"), 4); basket } diff --git a/exercises/modules/modules1.rs b/exercises/modules/modules1.rs index 9eb5a48b..a26f5c45 100644 --- a/exercises/modules/modules1.rs +++ b/exercises/modules/modules1.rs @@ -3,15 +3,13 @@ // Execute `rustlings hint modules1` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE - mod sausage_factory { // Don't let anybody outside of this module see this! fn get_secret_recipe() -> String { String::from("Ginger") } - fn make_sausage() { + pub fn make_sausage() { get_secret_recipe(); println!("sausage!"); } diff --git a/exercises/modules/modules2.rs b/exercises/modules/modules2.rs index 04154543..32297a6f 100644 --- a/exercises/modules/modules2.rs +++ b/exercises/modules/modules2.rs @@ -7,14 +7,13 @@ // Execute `rustlings hint modules2` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE - mod delicious_snacks { // TODO: Fix these use statements - use self::fruits::PEAR as ??? - use self::veggies::CUCUMBER as ??? + pub(crate) use self::fruits::PEAR as fruit; + pub(crate) use self::veggies::CUCUMBER as veggie; mod fruits { + // I can't remove the pub otherwise these constants won't be visible outside pub const PEAR: &'static str = "Pear"; pub const APPLE: &'static str = "Apple"; } @@ -26,6 +25,10 @@ mod delicious_snacks { } fn main() { + // This won't work --- fruits is a private mod + // println!("let's try to use it this way {}", + // delicious_snacks::fruits::PEAR + // ); println!( "favorite snacks: {} and {}", delicious_snacks::fruit, diff --git a/exercises/modules/modules3.rs b/exercises/modules/modules3.rs index f2bb0503..d1e3ab4f 100644 --- a/exercises/modules/modules3.rs +++ b/exercises/modules/modules3.rs @@ -8,10 +8,8 @@ // Execute `rustlings hint modules3` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE - // TODO: Complete this use statement -use ??? +use std::time::{SystemTime, UNIX_EPOCH}; fn main() { match SystemTime::now().duration_since(UNIX_EPOCH) {