diff --git a/dev/Cargo.toml b/dev/Cargo.toml index 4f725b704b..66bc1dfea0 100644 --- a/dev/Cargo.toml +++ b/dev/Cargo.toml @@ -150,14 +150,14 @@ bin = [ { name = "iterators4_sol", path = "../solutions/18_iterators/iterators4.rs" }, { name = "iterators5", path = "../exercises/18_iterators/iterators5.rs" }, { name = "iterators5_sol", path = "../solutions/18_iterators/iterators5.rs" }, - { name = "box1", path = "../exercises/19_smart_pointers/box1.rs" }, - { name = "box1_sol", path = "../solutions/19_smart_pointers/box1.rs" }, - { name = "rc1", path = "../exercises/19_smart_pointers/rc1.rs" }, - { name = "rc1_sol", path = "../solutions/19_smart_pointers/rc1.rs" }, - { name = "arc1", path = "../exercises/19_smart_pointers/arc1.rs" }, - { name = "arc1_sol", path = "../solutions/19_smart_pointers/arc1.rs" }, - { name = "cow1", path = "../exercises/19_smart_pointers/cow1.rs" }, - { name = "cow1_sol", path = "../solutions/19_smart_pointers/cow1.rs" }, + { name = "smart_pointers1", path = "../exercises/19_smart_pointers/smart_pointers1.rs" }, + { name = "smart_pointers1_sol", path = "../solutions/19_smart_pointers/smart_pointers1.rs" }, + { name = "smart_pointers2", path = "../exercises/19_smart_pointers/smart_pointers2.rs" }, + { name = "smart_pointers2_sol", path = "../solutions/19_smart_pointers/smart_pointers2.rs" }, + { name = "smart_pointers3", path = "../exercises/19_smart_pointers/smart_pointers3.rs" }, + { name = "smart_pointers3_sol", path = "../solutions/19_smart_pointers/smart_pointers3.rs" }, + { name = "smart_pointers4", path = "../exercises/19_smart_pointers/smart_pointers4.rs" }, + { name = "smart_pointers4_sol", path = "../solutions/19_smart_pointers/smart_pointers4.rs" }, { name = "threads1", path = "../exercises/20_threads/threads1.rs" }, { name = "threads1_sol", path = "../solutions/20_threads/threads1.rs" }, { name = "threads2", path = "../exercises/20_threads/threads2.rs" }, @@ -178,16 +178,16 @@ bin = [ { name = "clippy2_sol", path = "../solutions/22_clippy/clippy2.rs" }, { name = "clippy3", path = "../exercises/22_clippy/clippy3.rs" }, { name = "clippy3_sol", path = "../solutions/22_clippy/clippy3.rs" }, - { name = "using_as", path = "../exercises/23_conversions/using_as.rs" }, - { name = "using_as_sol", path = "../solutions/23_conversions/using_as.rs" }, - { name = "from_into", path = "../exercises/23_conversions/from_into.rs" }, - { name = "from_into_sol", path = "../solutions/23_conversions/from_into.rs" }, - { name = "from_str", path = "../exercises/23_conversions/from_str.rs" }, - { name = "from_str_sol", path = "../solutions/23_conversions/from_str.rs" }, - { name = "try_from_into", path = "../exercises/23_conversions/try_from_into.rs" }, - { name = "try_from_into_sol", path = "../solutions/23_conversions/try_from_into.rs" }, - { name = "as_ref_mut", path = "../exercises/23_conversions/as_ref_mut.rs" }, - { name = "as_ref_mut_sol", path = "../solutions/23_conversions/as_ref_mut.rs" }, + { name = "conversions1", path = "../exercises/23_conversions/conversions1.rs" }, + { name = "conversions1_sol", path = "../solutions/23_conversions/conversions1.rs" }, + { name = "conversions2", path = "../exercises/23_conversions/conversions2.rs" }, + { name = "conversions2_sol", path = "../solutions/23_conversions/conversions2.rs" }, + { name = "conversions3", path = "../exercises/23_conversions/conversions3.rs" }, + { name = "conversions3_sol", path = "../solutions/23_conversions/conversions3.rs" }, + { name = "conversions4", path = "../exercises/23_conversions/conversions4.rs" }, + { name = "conversions4_sol", path = "../solutions/23_conversions/conversions4.rs" }, + { name = "conversions5", path = "../exercises/23_conversions/conversions5.rs" }, + { name = "conversions5_sol", path = "../solutions/23_conversions/conversions5.rs" }, ] [package] diff --git a/exercises/19_smart_pointers/box1.rs b/exercises/19_smart_pointers/smart_pointers1.rs similarity index 100% rename from exercises/19_smart_pointers/box1.rs rename to exercises/19_smart_pointers/smart_pointers1.rs diff --git a/exercises/19_smart_pointers/rc1.rs b/exercises/19_smart_pointers/smart_pointers2.rs similarity index 100% rename from exercises/19_smart_pointers/rc1.rs rename to exercises/19_smart_pointers/smart_pointers2.rs diff --git a/exercises/19_smart_pointers/arc1.rs b/exercises/19_smart_pointers/smart_pointers3.rs similarity index 100% rename from exercises/19_smart_pointers/arc1.rs rename to exercises/19_smart_pointers/smart_pointers3.rs diff --git a/exercises/19_smart_pointers/cow1.rs b/exercises/19_smart_pointers/smart_pointers4.rs similarity index 100% rename from exercises/19_smart_pointers/cow1.rs rename to exercises/19_smart_pointers/smart_pointers4.rs diff --git a/exercises/23_conversions/README.md b/exercises/23_conversions/README.md index 619a78c565..fe3373312d 100644 --- a/exercises/23_conversions/README.md +++ b/exercises/23_conversions/README.md @@ -2,14 +2,14 @@ Rust offers a multitude of ways to convert a value of a given type into another type. -The simplest form of type conversion is a type cast expression. It is denoted with the binary operator `as`. For instance, `println!("{}", 1 + 1.0);` would not compile, since `1` is an integer while `1.0` is a float. However, `println!("{}", 1 as f32 + 1.0)` should compile. The exercise [`using_as`](using_as.rs) tries to cover this. +The simplest form of type conversion is a type cast expression. It is denoted with the binary operator `as`. For instance, `println!("{}", 1 + 1.0);` would not compile, since `1` is an integer while `1.0` is a float. However, `println!("{}", 1 as f32 + 1.0)` should compile. The exercise [`conversions1`](conversions1.rs) tries to cover this. Rust also offers traits that facilitate type conversions upon implementation. These traits can be found under the [`convert`](https://doc.rust-lang.org/std/convert/index.html) module. The traits are the following: -- `From` and `Into` covered in [`from_into`](from_into.rs) -- `TryFrom` and `TryInto` covered in [`try_from_into`](try_from_into.rs) -- `AsRef` and `AsMut` covered in [`as_ref_mut`](as_ref_mut.rs) +- `From` and `Into` covered in [`conversions2`](conversions2.rs) +- `TryFrom` and `TryInto` covered in [`conversions4`](conversions4.rs) +- `AsRef` and `AsMut` covered in [`conversions5`](conversions5.rs) Furthermore, the `std::str` module offers a trait called [`FromStr`](https://doc.rust-lang.org/std/str/trait.FromStr.html) which helps with converting strings into target types via the `parse` method on strings. If properly implemented for a given type `Person`, then `let p: Person = "Mark,20".parse().unwrap()` should both compile and run without panicking. diff --git a/exercises/23_conversions/using_as.rs b/exercises/23_conversions/conversions1.rs similarity index 100% rename from exercises/23_conversions/using_as.rs rename to exercises/23_conversions/conversions1.rs diff --git a/exercises/23_conversions/from_into.rs b/exercises/23_conversions/conversions2.rs similarity index 100% rename from exercises/23_conversions/from_into.rs rename to exercises/23_conversions/conversions2.rs diff --git a/exercises/23_conversions/from_str.rs b/exercises/23_conversions/conversions3.rs similarity index 100% rename from exercises/23_conversions/from_str.rs rename to exercises/23_conversions/conversions3.rs diff --git a/exercises/23_conversions/try_from_into.rs b/exercises/23_conversions/conversions4.rs similarity index 100% rename from exercises/23_conversions/try_from_into.rs rename to exercises/23_conversions/conversions4.rs diff --git a/exercises/23_conversions/as_ref_mut.rs b/exercises/23_conversions/conversions5.rs similarity index 100% rename from exercises/23_conversions/as_ref_mut.rs rename to exercises/23_conversions/conversions5.rs diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml index ae6e24a9af..637283d25e 100644 --- a/rustlings-macros/info.toml +++ b/rustlings-macros/info.toml @@ -959,7 +959,7 @@ a different method that could make your code more compact than using `fold`.""" # SMART POINTERS [[exercises]] -name = "box1" +name = "smart_pointers1" dir = "19_smart_pointers" hint = """ The compiler's message should help: Since we cannot store the value of the @@ -976,7 +976,7 @@ Although the current list is one of integers (`i32`), feel free to change the definition and try other types!""" [[exercises]] -name = "rc1" +name = "smart_pointers2" dir = "19_smart_pointers" hint = """ This is a straightforward exercise to use the `Rc` type. Each `Planet` has @@ -993,7 +993,7 @@ See more at: https://doc.rust-lang.org/book/ch15-04-rc.html Unfortunately, Pluto is no longer considered a planet :(""" [[exercises]] -name = "arc1" +name = "smart_pointers3" dir = "19_smart_pointers" test = false hint = """ @@ -1010,7 +1010,7 @@ Book: https://doc.rust-lang.org/book/ch16-00-concurrency.html""" [[exercises]] -name = "cow1" +name = "smart_pointers4" dir = "19_smart_pointers" hint = """ If `Cow` already owns the data, it doesn't need to clone it when `to_mut()` is @@ -1161,20 +1161,20 @@ hint = "No hints this time!" # TYPE CONVERSIONS [[exercises]] -name = "using_as" +name = "conversions1" dir = "23_conversions" hint = """ Use the `as` operator to cast one of the operands in the last line of the `average` function into the expected return type.""" [[exercises]] -name = "from_into" +name = "conversions2" dir = "23_conversions" hint = """ Follow the steps provided right before the `From` implementation.""" [[exercises]] -name = "from_str" +name = "conversions3" dir = "23_conversions" hint = """ The implementation of `FromStr` should return an `Ok` with a `Person` object, @@ -1191,7 +1191,7 @@ operator in your solution, you might want to look at https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/reenter_question_mark.html""" [[exercises]] -name = "try_from_into" +name = "conversions4" dir = "23_conversions" hint = """ Is there an implementation of `TryFrom` in the standard library that can both do @@ -1201,7 +1201,7 @@ Challenge: Can you make the `TryFrom` implementations generic over many integer types?""" [[exercises]] -name = "as_ref_mut" +name = "conversions5" dir = "23_conversions" hint = """ Add `AsRef` or `AsMut` as a trait bound to the functions.""" diff --git a/solutions/19_smart_pointers/box1.rs b/solutions/19_smart_pointers/smart_pointers1.rs similarity index 100% rename from solutions/19_smart_pointers/box1.rs rename to solutions/19_smart_pointers/smart_pointers1.rs diff --git a/solutions/19_smart_pointers/rc1.rs b/solutions/19_smart_pointers/smart_pointers2.rs similarity index 100% rename from solutions/19_smart_pointers/rc1.rs rename to solutions/19_smart_pointers/smart_pointers2.rs diff --git a/solutions/19_smart_pointers/arc1.rs b/solutions/19_smart_pointers/smart_pointers3.rs similarity index 100% rename from solutions/19_smart_pointers/arc1.rs rename to solutions/19_smart_pointers/smart_pointers3.rs diff --git a/solutions/19_smart_pointers/cow1.rs b/solutions/19_smart_pointers/smart_pointers4.rs similarity index 100% rename from solutions/19_smart_pointers/cow1.rs rename to solutions/19_smart_pointers/smart_pointers4.rs diff --git a/solutions/23_conversions/using_as.rs b/solutions/23_conversions/conversions1.rs similarity index 100% rename from solutions/23_conversions/using_as.rs rename to solutions/23_conversions/conversions1.rs diff --git a/solutions/23_conversions/from_into.rs b/solutions/23_conversions/conversions2.rs similarity index 100% rename from solutions/23_conversions/from_into.rs rename to solutions/23_conversions/conversions2.rs diff --git a/solutions/23_conversions/from_str.rs b/solutions/23_conversions/conversions3.rs similarity index 100% rename from solutions/23_conversions/from_str.rs rename to solutions/23_conversions/conversions3.rs diff --git a/solutions/23_conversions/try_from_into.rs b/solutions/23_conversions/conversions4.rs similarity index 100% rename from solutions/23_conversions/try_from_into.rs rename to solutions/23_conversions/conversions4.rs diff --git a/solutions/23_conversions/as_ref_mut.rs b/solutions/23_conversions/conversions5.rs similarity index 100% rename from solutions/23_conversions/as_ref_mut.rs rename to solutions/23_conversions/conversions5.rs