From 27b9360c21847c9cedab82a6300fdb1bcfbc2d76 Mon Sep 17 00:00:00 2001 From: Phan Huy Hoang Date: Wed, 4 Jan 2023 00:41:31 +0700 Subject: [PATCH] [Add] exercises/modules --- exercises/modules/modules1.rs | 4 +--- exercises/modules/modules2.rs | 6 ++---- exercises/modules/modules3.rs | 5 +---- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/exercises/modules/modules1.rs b/exercises/modules/modules1.rs index 8dd0e402..09d5ab3e 100644 --- a/exercises/modules/modules1.rs +++ b/exercises/modules/modules1.rs @@ -1,15 +1,13 @@ // modules1.rs // 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 c30a3897..65ea5a83 100644 --- a/exercises/modules/modules2.rs +++ b/exercises/modules/modules2.rs @@ -3,12 +3,10 @@ // 'use' and 'as' keywords. Fix these 'use' statements to make the code compile. // 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 use self::fruits::PEAR as fruit; + pub use self::veggies::CUCUMBER as veggie; mod fruits { pub const PEAR: &'static str = "Pear"; diff --git a/exercises/modules/modules3.rs b/exercises/modules/modules3.rs index 35e07990..0dd0c3f0 100644 --- a/exercises/modules/modules3.rs +++ b/exercises/modules/modules3.rs @@ -5,10 +5,7 @@ // from the std::time module. Bonus style points if you can do it with one line! // 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::*; fn main() { match SystemTime::now().duration_since(UNIX_EPOCH) {