summaryrefslogtreecommitdiff
path: root/strings/strings2.rs
blob: 235468b3690247797e8aabc8c42edd71c3634266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Make me compile without changing the function signature! Scroll down for hints :)

fn main() {
    let guess1 = "blue".to_string(); // Try not changing this line :)
    let correct = guess_favorite_color(guess1);
    if correct {
        println!("You guessed correctly!");
    } else {
        println!("Nope, that's not it.");
    }
}

fn guess_favorite_color(attempt: &str) -> bool {
    attempt == "green"
}
























// Yes, it would be really easy to fix this by just changing the value bound to `guess1` to be a
// string slice instead of a `String`, wouldn't it?? There is a way to add one character to line
// 5, though, that will coerce the `String` into a string slice.