mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-09 20:29:18 +00:00
commit
d8d856714e
@ -16,12 +16,15 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn fruit_basket() -> HashMap<String, u32> {
|
||||
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
|
||||
}
|
||||
|
||||
@ -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!");
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user