From 6dcecb38a4435593beb87c8e12d6314143631482 Mon Sep 17 00:00:00 2001 From: marisa Date: Mon, 11 Nov 2019 13:46:42 +0100 Subject: [PATCH] fix(strings): Move Strings before Structs Closes #204. --- exercises/test2.rs | 41 +++++++++++++++++++++-------------------- exercises/test3.rs | 43 +++++++++++++++++++++---------------------- info.toml | 34 +++++++++++++++++----------------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/exercises/test2.rs b/exercises/test2.rs index 75a4739..7fe81c6 100644 --- a/exercises/test2.rs +++ b/exercises/test2.rs @@ -1,27 +1,28 @@ // test2.rs // This is a test for the following sections: -// - Tests +// - Strings -// This test isn't testing our function -- make it do that in such a way that -// the test passes. Then write a second test that tests that we get the result -// we expect to get when we call `times_two` with a negative number. -// No hints, you can do this :) +// Ok, here are a bunch of values-- some are `Strings`, some are `&strs`. 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! -pub fn times_two(num: i32) -> i32 { - num * 2 +fn string_slice(arg: &str) { + println!("{}", arg); +} +fn string(arg: String) { + println!("{}", arg); } -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn returns_twice_of_positive_numbers() { - assert_eq!(times_two(4), ???); - } - - #[test] - fn returns_twice_of_negative_numbers() { - // TODO write an assert for `times_two(-4)` - } +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/exercises/test3.rs b/exercises/test3.rs index c8a5578..9a72118 100644 --- a/exercises/test3.rs +++ b/exercises/test3.rs @@ -1,28 +1,27 @@ -// strings3.rs +// test3.rs // This is a test for the following sections: -// - Strings +// - Tests -// Ok, here are a bunch of values-- some are `Strings`, some are `&strs`. 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! +// This test isn't testing our function -- make it do that in such a way that +// the test passes. Then write a second test that tests that we get the result +// we expect to get when we call `times_two` with a negative number. +// No hints, you can do this :) -fn string_slice(arg: &str) { - println!("{}", arg); -} -fn string(arg: String) { - println!("{}", arg); +pub fn times_two(num: i32) -> i32 { + num * 2 } -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()); +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn returns_twice_of_positive_numbers() { + assert_eq!(times_two(4), ???); + } + + #[test] + fn returns_twice_of_negative_numbers() { + // TODO write an assert for `times_two(-4)` + } } diff --git a/info.toml b/info.toml index 454d358..89222c4 100644 --- a/info.toml +++ b/info.toml @@ -86,6 +86,22 @@ mode = "test" path = "exercises/structs/structs2.rs" mode = "test" +# STRINGS + +[[exercises]] +path = "exercises/strings/strings1.rs" +mode = "compile" + +[[exercises]] +path = "exercises/strings/strings2.rs" +mode = "compile" + +# TEST 2 + +[[exercises]] +path = "exercises/test2.rs" +mode = "compile" + # ENUMS [[exercises]] @@ -114,27 +130,11 @@ mode = "test" path = "exercises/tests/tests3.rs" mode = "test" -# TEST 2 - -[[exercises]] -path = "exercises/test2.rs" -mode = "test" - -# STRINGS - -[[exercises]] -path = "exercises/strings/strings1.rs" -mode = "compile" - -[[exercises]] -path = "exercises/strings/strings2.rs" -mode = "compile" - # TEST 3 [[exercises]] path = "exercises/test3.rs" -mode = "compile" +mode = "test" # MODULES