mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-10 12:49:18 +00:00
add module3 exercise that shows uses of modules from std
This commit is contained in:
parent
90959f4549
commit
0ca528f8d0
17
exercises/modules/modules3.rs
Normal file
17
exercises/modules/modules3.rs
Normal file
@ -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!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
10
info.toml
10
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
|
associated constants). It's almost there except for one keyword missing for
|
||||||
each constant."""
|
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
|
# COLLECTIONS
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user