2018-02-22 06:09:53 +00:00
|
|
|
// strings3.rs
|
2019-01-23 19:48:01 +00:00
|
|
|
// This is a test for the following sections:
|
|
|
|
// - Strings
|
|
|
|
|
2015-09-20 23:03:00 +01: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!
|
|
|
|
|
|
|
|
fn string_slice(arg: &str) { println!("{}", arg); }
|
|
|
|
fn string(arg: String) { println!("{}", arg); }
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
("blue");
|
|
|
|
("red".to_string());
|
|
|
|
(String::from("hi"));
|
2015-10-04 16:42:09 +01:00
|
|
|
("rust is fun!".to_owned());
|
|
|
|
("nice weather".into());
|
2015-09-20 23:03:00 +01: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());
|
|
|
|
}
|