mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-25 00:00:05 +03:00
thematically refactor modules2
This commit is contained in:
parent
f447adef8f
commit
05f65d67ae
|
@ -1,25 +1,25 @@
|
||||||
// modules2.rs
|
// modules2.rs
|
||||||
// Make me compile! Scroll down for hints :)
|
// Make me compile! Scroll down for hints :)
|
||||||
|
|
||||||
mod us_presidential_frontrunners {
|
mod delicious_snacks {
|
||||||
use self::democrats::HILLARY_CLINTON as democrat;
|
use self::fruits::PEAR as fruit;
|
||||||
use self::republicans::DONALD_TRUMP as republican;
|
use self::veggies::CUCUMBER as veggie;
|
||||||
|
|
||||||
mod democrats {
|
mod fruits {
|
||||||
pub const HILLARY_CLINTON: &'static str = "Hillary Clinton";
|
pub const PEAR: &'static str = "Pear";
|
||||||
pub const BERNIE_SANDERS: &'static str = "Bernie Sanders";
|
pub const APPLE: &'static str = "Apple";
|
||||||
}
|
}
|
||||||
|
|
||||||
mod republicans {
|
mod veggies {
|
||||||
pub const DONALD_TRUMP: &'static str = "Donald Trump";
|
pub const CUCUMBER: &'static str = "Cucumber";
|
||||||
pub const JEB_BUSH: &'static str = "Jeb Bush";
|
pub const CARROT: &'static str = "Carrot";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("candidates: {} and {}",
|
println!("favorite snacks: {} and {}",
|
||||||
us_presidential_frontrunners::democrat,
|
delicious_snacks::fruit,
|
||||||
us_presidential_frontrunners::republican);
|
delicious_snacks::veggie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ fn main() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The us_presidential_frontrunners module is trying to present an external
|
// The delicious_snacks module is trying to present an external
|
||||||
// interface (the `democrat` and `republican` constants) that is different than
|
// interface (the `fruit` and `veggie` constants) that is different than
|
||||||
// its internal structure (the `democrats` and `republicans` modules and
|
// 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.
|
||||||
|
|
Loading…
Reference in a new issue