complete: strings
This commit is contained in:
parent
26374eb122
commit
192725b336
exercises
|
@ -7,8 +7,6 @@
|
|||
// you think each value is. That is, add either `string_slice` or `string`
|
||||
// before the parentheses on each line. If you're right, it will compile!
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn string_slice(arg: &str) {
|
||||
println!("{}", arg);
|
||||
}
|
||||
|
@ -17,14 +15,14 @@ fn string(arg: String) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
???("blue");
|
||||
???("red".to_string());
|
||||
???(String::from("hi"));
|
||||
???("rust is fun!".to_owned());
|
||||
???("nice weather".into());
|
||||
???(format!("Interpolation {}", "Station"));
|
||||
???(&String::from("abc")[0..1]);
|
||||
???(" hello there ".trim());
|
||||
???("Happy Monday!".to_string().replace("Mon", "Tues"));
|
||||
???("mY sHiFt KeY iS sTiCkY".to_lowercase());
|
||||
string_slice("blue");
|
||||
string_slice(" hello there ".trim());
|
||||
string_slice(&String::from("abc")[0..1]);
|
||||
string("red".to_string());
|
||||
string(String::from("hi"));
|
||||
string("rust is fun!".to_owned());
|
||||
string("nice weather".into());
|
||||
string(format!("Interpolation {}", "Station"));
|
||||
string("Happy Monday!".to_string().replace("Mon", "Tues"));
|
||||
string("mY sHiFt KeY iS sTiCkY".to_lowercase());
|
||||
}
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
// Make me compile without changing the function signature!
|
||||
// Execute `rustlings hint strings1` for hints ;)
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn main() {
|
||||
let answer = current_favorite_color();
|
||||
println!("My current favorite color is {}", answer);
|
||||
}
|
||||
|
||||
fn current_favorite_color() -> String {
|
||||
"blue"
|
||||
String::from("red")
|
||||
}
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
// Make me compile without changing the function signature!
|
||||
// Execute `rustlings hint strings2` for hints :)
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn main() {
|
||||
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!");
|
||||
} else {
|
||||
println!("That is not a color word I know.");
|
||||
|
|
Loading…
Reference in a new issue