diff options
Diffstat (limited to 'exercises/strings/strings3.rs')
| -rwxr-xr-x | exercises/strings/strings3.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/exercises/strings/strings3.rs b/exercises/strings/strings3.rs new file mode 100755 index 0000000..b6f6a1e --- /dev/null +++ b/exercises/strings/strings3.rs @@ -0,0 +1,21 @@ +// strings3.rs +// 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")); + ("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()); +} |
