2018-02-22 08:09:53 +02:00
|
|
|
// strings3.rs
|
2019-01-23 21:48:01 +02:00
|
|
|
// This is a test for the following sections:
|
|
|
|
// - Strings
|
|
|
|
|
2015-09-21 00:03:00 +02:00
|
|
|
// Ok, here are a bunch of values-- some are `Strings`, some are `&strs`. 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!
|
|
|
|
|
2019-06-07 04:52:42 +02:00
|
|
|
fn string_slice(arg: &str) {
|
|
|
|
println!("{}", arg);
|
|
|
|
}
|
|
|
|
fn string(arg: String) {
|
|
|
|
println!("{}", arg);
|
|
|
|
}
|
2015-09-21 00:03:00 +02:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
("blue");
|
|
|
|
("red".to_string());
|
|
|
|
(String::from("hi"));
|
2015-10-04 17:42:09 +02:00
|
|
|
("rust is fun!".to_owned());
|
|
|
|
("nice weather".into());
|
2015-09-21 00:03:00 +02:00
|
|
|
(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());
|
|
|
|
}
|