summaryrefslogtreecommitdiff
path: root/exercises/strings
diff options
context:
space:
mode:
authorAdam Brewer <adamhb321@gmail.com>2023-10-16 07:37:12 -0400
committerAdam Brewer <adamhb321@gmail.com>2023-10-16 07:37:12 -0400
commit64d95837e9813541cf5b357de13865ce687ae98d (patch)
treef022c5d5ba01128811c0b77618a7adb843ee876b /exercises/strings
parentc3941323e2c0b9ee286494327de92e00f23b9e3a (diff)
Update Exercises Directory Names to Reflect Order
Diffstat (limited to 'exercises/strings')
-rw-r--r--exercises/strings/README.md9
-rw-r--r--exercises/strings/strings1.rs17
-rw-r--r--exercises/strings/strings2.rs21
-rw-r--r--exercises/strings/strings3.rs45
-rw-r--r--exercises/strings/strings4.rs30
5 files changed, 0 insertions, 122 deletions
diff --git a/exercises/strings/README.md b/exercises/strings/README.md
deleted file mode 100644
index fa2104c..0000000
--- a/exercises/strings/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Strings
-
-Rust has two string types, a string slice (`&str`) and an owned string (`String`).
-We're not going to dictate when you should use which one, but we'll show you how
-to identify and create them, as well as use them.
-
-## Further information
-
-- [Strings](https://doc.rust-lang.org/book/ch08-02-strings.html)
diff --git a/exercises/strings/strings1.rs b/exercises/strings/strings1.rs
deleted file mode 100644
index f50e1fa..0000000
--- a/exercises/strings/strings1.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-// strings1.rs
-//
-// Make me compile without changing the function signature!
-//
-// Execute `rustlings hint strings1` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
-fn main() {
- let answer = current_favorite_color();
- println!("My current favorite color is {}", answer);
-}
-
-fn current_favorite_color() -> String {
- "blue"
-}
diff --git a/exercises/strings/strings2.rs b/exercises/strings/strings2.rs
deleted file mode 100644
index 4d95d16..0000000
--- a/exercises/strings/strings2.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// strings2.rs
-//
-// Make me compile without changing the function signature!
-//
-// Execute `rustlings hint strings2` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
-fn main() {
- let word = String::from("green"); // Try not changing this line :)
- if is_a_color_word(word) {
- println!("That is a color word I know!");
- } else {
- println!("That is not a color word I know.");
- }
-}
-
-fn is_a_color_word(attempt: &str) -> bool {
- attempt == "green" || attempt == "blue" || attempt == "red"
-}
diff --git a/exercises/strings/strings3.rs b/exercises/strings/strings3.rs
deleted file mode 100644
index b29f932..0000000
--- a/exercises/strings/strings3.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-// strings3.rs
-//
-// Execute `rustlings hint strings3` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
-fn trim_me(input: &str) -> String {
- // TODO: Remove whitespace from both ends of a string!
- ???
-}
-
-fn compose_me(input: &str) -> String {
- // TODO: Add " world!" to the string! There's multiple ways to do this!
- ???
-}
-
-fn replace_me(input: &str) -> String {
- // TODO: Replace "cars" in the string with "balloons"!
- ???
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn trim_a_string() {
- assert_eq!(trim_me("Hello! "), "Hello!");
- assert_eq!(trim_me(" What's up!"), "What's up!");
- assert_eq!(trim_me(" Hola! "), "Hola!");
- }
-
- #[test]
- fn compose_a_string() {
- assert_eq!(compose_me("Hello"), "Hello world!");
- assert_eq!(compose_me("Goodbye"), "Goodbye world!");
- }
-
- #[test]
- fn replace_a_string() {
- assert_eq!(replace_me("I think cars are cool"), "I think balloons are cool");
- assert_eq!(replace_me("I love to look at cars"), "I love to look at balloons");
- }
-}
diff --git a/exercises/strings/strings4.rs b/exercises/strings/strings4.rs
deleted file mode 100644
index e8c54ac..0000000
--- a/exercises/strings/strings4.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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());
-}