rustlings/exercises/test2.rs

29 lines
845 B
Rust
Raw Normal View History

2019-01-23 14:48:01 -05:00
// test2.rs
// This is a test for the following sections:
// - Strings
2019-01-23 14:48:01 -05: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!
2015-09-20 18:31:41 -04:00
fn string_slice(arg: &str) {
println!("{}", arg);
}
fn string(arg: String) {
println!("{}", arg);
2015-09-20 18:31:41 -04:00
}
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());
2015-09-20 18:31:41 -04:00
}