From 0ca528f8d0a5e1f2b9324b84375577d9704ab7a5 Mon Sep 17 00:00:00 2001 From: Shmulik Cohen Date: Fri, 13 Aug 2021 14:03:09 +0300 Subject: [PATCH] add module3 exercise that shows uses of modules from std --- exercises/modules/modules3.rs | 17 +++++++++++++++++ info.toml | 10 ++++++++++ 2 files changed, 27 insertions(+) create mode 100644 exercises/modules/modules3.rs diff --git a/exercises/modules/modules3.rs b/exercises/modules/modules3.rs new file mode 100644 index 00000000..8a1f9e21 --- /dev/null +++ b/exercises/modules/modules3.rs @@ -0,0 +1,17 @@ +// modules3.rs +// You can use the 'use' keyword to bring module paths from modules from anywere +// and espically from the rust standard library. Bring SystemTime and UNIX_EPOCH +// from the std::time module. Bonus style points if you can do it with one line! +// Make me compile! Execute `rustlings hint modules3` for hints :) + +// I AM NOT DONE + +// TODO: Complete this use statement +use ??? + +fn main() { + match SystemTime::now().duration_since(UNIX_EPOCH) { + Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()), + Err(_) => panic!("SystemTime before UNIX EPOCH!"), + } +} diff --git a/info.toml b/info.toml index d5008ede..a47d03ed 100644 --- a/info.toml +++ b/info.toml @@ -368,6 +368,16 @@ its internal structure (the `fruits` and `veggies` modules and associated constants). It's almost there except for one keyword missing for each constant.""" +[[exercises]] +name = "modules3" +path = "exercises/modules/modules3.rs" +mode = "compile" +hint = """ +UNIX_EPOCH and SystemTime declared in the std::time module, add a use statement +for these two to bring them into scope. You can use nested paths or the glob +operator to bring these two in one line +""" + # COLLECTIONS [[exercises]]