From 64d95837e9813541cf5b357de13865ce687ae98d Mon Sep 17 00:00:00 2001 From: Adam Brewer Date: Mon, 16 Oct 2023 07:37:12 -0400 Subject: Update Exercises Directory Names to Reflect Order --- exercises/strings/README.md | 9 --------- exercises/strings/strings1.rs | 17 ---------------- exercises/strings/strings2.rs | 21 -------------------- exercises/strings/strings3.rs | 45 ------------------------------------------- exercises/strings/strings4.rs | 30 ----------------------------- 5 files changed, 122 deletions(-) delete mode 100644 exercises/strings/README.md delete mode 100644 exercises/strings/strings1.rs delete mode 100644 exercises/strings/strings2.rs delete mode 100644 exercises/strings/strings3.rs delete mode 100644 exercises/strings/strings4.rs (limited to 'exercises/strings') 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()); -} -- cgit v1.2.3