From f443f4e7b31467b29271aab477c63eb64aba1be3 Mon Sep 17 00:00:00 2001 From: mokou Date: Thu, 14 Jul 2022 13:01:40 +0200 Subject: [PATCH] feat: move quiz2 to be strings4 --- exercises/strings/strings4.rs | 29 +++++++++++++++++++++++++++++ info.toml | 11 ++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 exercises/strings/strings4.rs diff --git a/exercises/strings/strings4.rs b/exercises/strings/strings4.rs new file mode 100644 index 0000000..c410b56 --- /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 ec2d817..0f7d925 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"