mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
Compare commits
No commits in common. "64b2f18d92a0192977d15947472908ccfff35b5b" and "1bae2dcb0019d579cdfe5a0c68a9e46780eea6dd" have entirely different histories.
64b2f18d92
...
1bae2dcb00
|
@ -1,7 +1,7 @@
|
|||
// TODO: Fix the compiler error on this function.
|
||||
fn picky_eater(food: &str) -> &str {
|
||||
if food == "strawberry" {
|
||||
"Yummy!"
|
||||
fn foo_if_fizz(fizzish: &str) -> &str {
|
||||
if fizzish == "fizz" {
|
||||
"foo"
|
||||
} else {
|
||||
1
|
||||
}
|
||||
|
@ -18,20 +18,18 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn yummy_food() {
|
||||
// This means that calling `picky_eater` with the argument "food" should return "Yummy!".
|
||||
assert_eq!(picky_eater("strawberry"), "Yummy!");
|
||||
fn foo_for_fizz() {
|
||||
// This means that calling `foo_if_fizz` with the argument "fizz" should return "foo".
|
||||
assert_eq!(foo_if_fizz("fizz"), "foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn neutral_food() {
|
||||
assert_eq!(picky_eater("potato"), "I guess I can eat that.");
|
||||
fn bar_for_fuzz() {
|
||||
assert_eq!(foo_if_fizz("fuzz"), "bar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_disliked_food() {
|
||||
assert_eq!(picky_eater("broccoli"), "No thanks!");
|
||||
assert_eq!(picky_eater("gummy bears"), "No thanks!");
|
||||
assert_eq!(picky_eater("literally anything"), "No thanks!");
|
||||
fn default_to_baz() {
|
||||
assert_eq!(foo_if_fizz("literally anything"), "baz");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,7 @@ struct Point {
|
|||
}
|
||||
|
||||
enum Message {
|
||||
Resize { width: u64, height: u64 },
|
||||
Move(Point),
|
||||
Echo(String),
|
||||
ChangeColor(u8, u8, u8),
|
||||
Quit,
|
||||
// TODO: Implement the message variant types based on their usage below.
|
||||
}
|
||||
|
||||
struct State {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
fn picky_eater(food: &str) -> &str {
|
||||
if food == "strawberry" {
|
||||
"Yummy!"
|
||||
} else if food == "potato" {
|
||||
"I guess I can eat that."
|
||||
fn foo_if_fizz(fizzish: &str) -> &str {
|
||||
if fizzish == "fizz" {
|
||||
"foo"
|
||||
} else if fizzish == "fuzz" {
|
||||
"bar"
|
||||
} else {
|
||||
"No thanks!"
|
||||
"baz"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,19 +17,17 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn yummy_food() {
|
||||
assert_eq!(picky_eater("strawberry"), "Yummy!");
|
||||
fn foo_for_fizz() {
|
||||
assert_eq!(foo_if_fizz("fizz"), "foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn neutral_food() {
|
||||
assert_eq!(picky_eater("potato"), "I guess I can eat that.");
|
||||
fn bar_for_fuzz() {
|
||||
assert_eq!(foo_if_fizz("fuzz"), "bar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_disliked_food() {
|
||||
assert_eq!(picky_eater("broccoli"), "No thanks!");
|
||||
assert_eq!(picky_eater("gummy bears"), "No thanks!");
|
||||
assert_eq!(picky_eater("literally anything"), "No thanks!");
|
||||
fn default_to_baz() {
|
||||
assert_eq!(foo_if_fizz("literally anything"), "baz");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue