You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
865 B
31 lines
865 B
// strings4.rs
|
|
//
|
|
// Ok, here are a bunch of values-- some are `String`s, some are `&str`s. Your
|
|
// task is to call one of these two functions on each value depending on what
|
|
// 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!
|
|
//
|
|
// No hints this time!
|
|
|
|
// I AM NOT DONE
|
|
|
|
fn string_slice(arg: &str) {
|
|
println!("{}", arg);
|
|
}
|
|
fn string(arg: String) {
|
|
println!("{}", arg);
|
|
}
|
|
|
|
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());
|
|
}
|