2022-07-14 11:01:40 +00:00
|
|
|
// strings4.rs
|
2023-05-29 17:39:08 +00:00
|
|
|
//
|
2022-07-14 11:01:40 +00:00
|
|
|
// 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!
|
2023-05-29 17:39:08 +00:00
|
|
|
//
|
2022-07-14 11:01:40 +00:00
|
|
|
// No hints this time!
|
|
|
|
|
|
|
|
|
|
|
|
fn string_slice(arg: &str) {
|
|
|
|
println!("{}", arg);
|
|
|
|
}
|
|
|
|
fn string(arg: String) {
|
|
|
|
println!("{}", arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2023-09-10 16:38:07 +00:00
|
|
|
string_slice("blue");
|
|
|
|
string("red".to_string());
|
|
|
|
string(String::from("hi"));
|
|
|
|
string("rust is fun!".to_owned());
|
|
|
|
string_slice("nice weather".into());
|
|
|
|
string(format!("Interpolation {}", "Station"));
|
|
|
|
string_slice(&String::from("abc")[0..1]);
|
|
|
|
string_slice(" hello there ".trim());
|
|
|
|
string("Happy Monday!".to_string().replace("Mon", "Tues"));
|
|
|
|
string("mY sHiFt KeY iS sTiCkY".to_lowercase());
|
2022-07-14 11:01:40 +00:00
|
|
|
}
|