mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-12 21:59: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
|
// enums1.rs
|
||||||
// Make me compile! Execute `rustlings hint enums1` for hints!
|
// Make me compile! Execute `rustlings hint enums1` for hints!
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Message {
|
enum Message {
|
||||||
Quit,
|
// TODO: define a few types of messages as used below
|
||||||
Echo,
|
|
||||||
Move,
|
|
||||||
ChangeColor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
// enums2.rs
|
// enums2.rs
|
||||||
// Make me compile! Execute `rustlings hint enums2` for hints!
|
// Make me compile! Execute `rustlings hint enums2` for hints!
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Message {
|
enum Message {
|
||||||
Move{x: i32, y: i32},
|
// TODO: define the different variants used below
|
||||||
Echo(String),
|
|
||||||
ChangeColor(i32, i32, i32),
|
|
||||||
Quit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message {
|
impl Message {
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
// enums3.rs
|
// enums3.rs
|
||||||
// Address all the TODOs to make the tests pass!
|
// Address all the TODOs to make the tests pass!
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
|
|
||||||
enum Message {
|
enum Message {
|
||||||
ChangeColor((u8, u8, u8)),
|
// TODO: implement the message variant types based on their usage below
|
||||||
Echo(String),
|
|
||||||
Move(Point),
|
|
||||||
Quit,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Point {
|
struct Point {
|
||||||
@ -37,12 +36,7 @@ impl State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn process(&mut self, message: Message) {
|
fn process(&mut self, message: Message) {
|
||||||
match message {
|
// TODO: create a match expression to process the different message variants
|
||||||
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(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
// modules1.rs
|
// modules1.rs
|
||||||
// Make me compile! Execute `rustlings hint modules1` for hints :)
|
// Make me compile! Execute `rustlings hint modules1` for hints :)
|
||||||
|
|
||||||
|
// I AM NOT DONE
|
||||||
|
|
||||||
mod sausage_factory {
|
mod sausage_factory {
|
||||||
// Don't let anybody outside of this module see this!
|
// Don't let anybody outside of this module see this!
|
||||||
fn get_secret_recipe() -> String {
|
fn get_secret_recipe() -> String {
|
||||||
String::from("Ginger")
|
String::from("Ginger")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_sausage() {
|
fn make_sausage() {
|
||||||
get_secret_recipe();
|
get_secret_recipe();
|
||||||
println!("sausage!");
|
println!("sausage!");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user