summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authormokou <mokou@fastmail.com>2022-07-14 13:01:40 +0200
committermokou <mokou@fastmail.com>2022-07-14 13:01:40 +0200
commitf443f4e7b31467b29271aab477c63eb64aba1be3 (patch)
treed73381a429fb6a5f23433c1fa5566fe58c2eccf0 /exercises
parentab8572e15bf6765471490281ba2a1c8f88275e40 (diff)
feat: move quiz2 to be strings4
Diffstat (limited to 'exercises')
-rw-r--r--exercises/strings/strings4.rs29
1 files changed, 29 insertions, 0 deletions
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());
+}