diff --git a/exercises/strings/strings4.rs b/exercises/strings/strings4.rs new file mode 100644 index 00000000..c410b562 --- /dev/null +++ b/exercises/strings/strings4.rs @@ -0,0 +1,29 @@ +// strings4.rs + +// 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! +// No hints this time! + +// I AM NOT DONE + +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()); +} diff --git a/info.toml b/info.toml index ec2d8172..0f7d9253 100644 --- a/info.toml +++ b/info.toml @@ -167,7 +167,7 @@ For that first compiler error, it's important in Rust that each conditional block returns the same type! To get the tests passing, you will need a couple conditions checking different input values.""" -# TEST 1 +# QUIZ 1 [[exercises]] name = "quiz1" @@ -454,6 +454,12 @@ them! For the compose_me method: You can either use the `format!` macro, or convert the string slice into an owned string, which you can then freely extend.""" +[[exercises]] +name = "strings4" +path = "exercises/strings/strings4.rs" +mode = "compile" +hint = "No hints this time ;)" + # MODULES [[exercises]] @@ -517,8 +523,7 @@ Hint 2: If there is already an entry for a given key, the value returned by `ent Learn more at https://doc.rust-lang.org/book/ch08-03-hash-maps.html#updating-a-value-based-on-the-old-value """ - -# TEST 2 +# QUIZ 2 [[exercises]] name = "quiz2"