Complete string exercises (#10)
This commit is contained in:
parent
7226111d7d
commit
ca6fa0ad95
exercises/strings
|
@ -2,13 +2,11 @@
|
||||||
// Make me compile without changing the function signature!
|
// Make me compile without changing the function signature!
|
||||||
// Execute `rustlings hint strings1` for hints ;)
|
// Execute `rustlings hint strings1` for hints ;)
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let answer = current_favorite_color();
|
let answer = current_favorite_color();
|
||||||
println!("My current favorite color is {}", answer);
|
println!("My current favorite color is {}", answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn current_favorite_color() -> String {
|
fn current_favorite_color() -> String {
|
||||||
"blue"
|
"blue".to_string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,9 @@
|
||||||
// Make me compile without changing the function signature!
|
// Make me compile without changing the function signature!
|
||||||
// Execute `rustlings hint strings2` for hints :)
|
// Execute `rustlings hint strings2` for hints :)
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let word = String::from("green"); // Try not changing this line :)
|
let word = String::from("green"); // Try not changing this line :)
|
||||||
if is_a_color_word(word) {
|
if is_a_color_word(&word) {
|
||||||
println!("That is a color word I know!");
|
println!("That is a color word I know!");
|
||||||
} else {
|
} else {
|
||||||
println!("That is not a color word I know.");
|
println!("That is not a color word I know.");
|
||||||
|
|
Loading…
Reference in a new issue