mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 13:19:18 +00:00
Revert "did some more"
This reverts commit 9e3329d2779985e1dd046e6d852f5f1ad3b8de13.
This commit is contained in:
parent
5e5351139a
commit
3f7ddeb5c1
@ -1,12 +1,11 @@
|
||||
// enums1.rs
|
||||
// Make me compile! Execute `rustlings hint enums1` for hints!
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Message {
|
||||
Quit,
|
||||
Echo,
|
||||
Move,
|
||||
ChangeColor
|
||||
// TODO: define a few types of messages as used below
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
// enums2.rs
|
||||
// Make me compile! Execute `rustlings hint enums2` for hints!
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Message {
|
||||
Move{x: i32, y: i32},
|
||||
Echo(String),
|
||||
ChangeColor(i32, i32, i32),
|
||||
Quit
|
||||
// TODO: define the different variants used below
|
||||
}
|
||||
|
||||
impl Message {
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
// enums3.rs
|
||||
// Address all the TODOs to make the tests pass!
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
enum Message {
|
||||
ChangeColor((u8, u8, u8)),
|
||||
Echo(String),
|
||||
Move(Point),
|
||||
Quit,
|
||||
// TODO: implement the message variant types based on their usage below
|
||||
}
|
||||
|
||||
struct Point {
|
||||
@ -37,12 +36,7 @@ impl State {
|
||||
}
|
||||
|
||||
fn process(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::Move(point) => self.move_position(point),
|
||||
Message::ChangeColor((r, g ,b)) => self.change_color((r, g ,b)),
|
||||
Message::Echo(s) => self.echo(s),
|
||||
Message::Quit => self.quit(),
|
||||
}
|
||||
// TODO: create a match expression to process the different message variants
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
// modules1.rs
|
||||
// Make me compile! Execute `rustlings hint modules1` for hints :)
|
||||
|
||||
// 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")
|
||||
}
|
||||
|
||||
pub fn make_sausage() {
|
||||
fn make_sausage() {
|
||||
get_secret_recipe();
|
||||
println!("sausage!");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user