From d9b69bd1a0a7a99f2c0d80933ad2eea44c8c71b2 Mon Sep 17 00:00:00 2001 From: Juan Pablo Ramirez Date: Sun, 9 May 2021 17:58:54 -0500 Subject: [PATCH 1/7] fix: remove trailing whitespace --- exercises/structs/structs3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 8d8b471..a80d062 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -31,7 +31,7 @@ impl Package { } fn get_fees(&self, cents_per_gram: i32) -> ??? { - // Something goes here... + // Something goes here... } } From 31457940846b3844d78d4a4d2b074bc8d6aaf1eb Mon Sep 17 00:00:00 2001 From: Juan Pablo Ramirez Date: Tue, 11 May 2021 14:50:05 -0500 Subject: [PATCH 2/7] fix: add hints to generics1 and generics2 exercises --- exercises/generics/generics1.rs | 2 ++ exercises/generics/generics2.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/exercises/generics/generics1.rs b/exercises/generics/generics1.rs index 967287e..f93e64a 100644 --- a/exercises/generics/generics1.rs +++ b/exercises/generics/generics1.rs @@ -1,6 +1,8 @@ // This shopping list program isn't compiling! // Use your knowledge of generics to fix it. +// Execute `rustlings hint generics1` for hints! + // I AM NOT DONE fn main() { diff --git a/exercises/generics/generics2.rs b/exercises/generics/generics2.rs index 0cb59ad..1501529 100644 --- a/exercises/generics/generics2.rs +++ b/exercises/generics/generics2.rs @@ -1,6 +1,8 @@ // This powerful wrapper provides the ability to store a positive integer value. // Rewrite it using generics so that it supports wrapping ANY type. +// Execute `rustlings hint generics2` for hints! + // I AM NOT DONE struct Wrapper { From 4d4fa77459392acd3581c6068aa8be9a02de12fc Mon Sep 17 00:00:00 2001 From: Juan Pablo Ramirez Date: Wed, 12 May 2021 10:20:07 -0500 Subject: [PATCH 3/7] fix: remove trailing whitespaces from iterators1 --- exercises/standard_library_types/iterators1.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/standard_library_types/iterators1.rs b/exercises/standard_library_types/iterators1.rs index 3fd519d..4606ad3 100644 --- a/exercises/standard_library_types/iterators1.rs +++ b/exercises/standard_library_types/iterators1.rs @@ -1,11 +1,11 @@ // iterators1.rs -// +// // Make me compile by filling in the `???`s // // When performing operations on elements within a collection, iterators are essential. -// This module helps you get familiar with the structure of using an iterator and +// This module helps you get familiar with the structure of using an iterator and // how to go through elements within an iterable collection. -// +// // Execute `rustlings hint iterators1` for hints :D // I AM NOT DONE From 11d2cf0d604dee3f5023c17802d69438e69fa50e Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sat, 15 May 2021 14:01:17 -0500 Subject: [PATCH 4/7] fix(try_from_into, from_str): hints for dyn Error Add hints about how to return the correct type for functions that return `Result<_, Box`. Some feedback from Discord suggests that people run into trouble with that. --- info.toml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/info.toml b/info.toml index 82e1195..0535a77 100644 --- a/info.toml +++ b/info.toml @@ -893,7 +893,19 @@ path = "exercises/conversions/try_from_into.rs" mode = "test" hint = """ Follow the steps provided right before the `TryFrom` implementation. -You can also use the example at https://doc.rust-lang.org/std/convert/trait.TryFrom.html""" +You can also use the example at https://doc.rust-lang.org/std/convert/trait.TryFrom.html + +You might want to look back at the exercise errorsn (or its hints) to remind +yourself about how `Box` works. + +If you're trying to return a string as an error, note that neither `str` +nor `String` implements `error::Error`. However, there is an implementation +of `From<&str>` for `Box`. This means you can use `.into()` or +the `?` operator to convert your string into the correct error type. + +If you're having trouble with using the `?` operator to convert an error string, +recall that `?` works to convert `Err(something)` into the appropriate error +type for returning from the function.""" [[exercises]] name = "as_ref_mut" @@ -909,4 +921,7 @@ mode = "test" hint = """ The implementation of FromStr should return an Ok with a Person object, or an Err with an error if the string is not valid. -This is almost like the `try_from_into` exercise.""" +This is almost like the `try_from_into` exercise. + +If you're having trouble with returning the correct error type, see the +hints for try_from_into.""" From 399ab328d8d407265c09563aa4ef4534b2503ff2 Mon Sep 17 00:00:00 2001 From: Sateesh Date: Mon, 17 May 2021 17:40:40 +0530 Subject: [PATCH 5/7] feat: Add move_semantics5 exercise. (#746) * feat: Add move_semantics5 exercise. * feat: Add option3 exercise * Address review comments. Fix typos, sentence formatting. * Remove unwanted newline. * Address review comments: make comment inline, fix format in print. --- exercises/move_semantics/move_semantics5.rs | 14 ++++++++++++++ exercises/option/option3.rs | 19 +++++++++++++++++++ info.toml | 21 +++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 exercises/move_semantics/move_semantics5.rs create mode 100644 exercises/option/option3.rs diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs new file mode 100644 index 0000000..4f8128c --- /dev/null +++ b/exercises/move_semantics/move_semantics5.rs @@ -0,0 +1,14 @@ +// move_semantics5.rs +// Make me compile without adding any newlines or removing any of the lines. +// Execute `rustlings hint move_semantics5` for hints :) + +// I AM NOT DONE + +fn main() { + let mut x = 100; + let y = &mut x; + let z = &mut *y; + *y += 100; + *z += 1000; + assert_eq!(x, 1200); +} diff --git a/exercises/option/option3.rs b/exercises/option/option3.rs new file mode 100644 index 0000000..045d2ac --- /dev/null +++ b/exercises/option/option3.rs @@ -0,0 +1,19 @@ +// option3.rs +// Make me compile! Execute `rustlings hint option3` for hints + +// I AM NOT DONE + +struct Point { + x: i32, + y: i32, +} + +fn main() { + let y: Option = Some(Point { x: 100, y: 200 }); + + match y { + Some(p) => println!("Co-ordinates are {},{} ", p.x, p.y), + _ => println!("no match"), + } + y; // Fix without deleting this line. +} diff --git a/info.toml b/info.toml index 0535a77..0e9f428 100644 --- a/info.toml +++ b/info.toml @@ -210,6 +210,17 @@ So the end goal is to: - since we're not creating a new vec in `main` anymore, we need to create a new vec in `fill_vec`, similarly to the way we did in `main`""" +[[exercises]] +name = "move_semantics5" +path = "exercises/move_semantics/move_semantics5.rs" +mode = "compile" +hint = """ +Carefully reason about the range in which each mutable reference is in +vogue. Does updating the value of referrent (x) immediately after the +mutable reference is taken helps? Read more about 'Mutable Referenes' +in the book's section References and Borrowing': +https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.""" + # PRIMITIVE TYPES [[exercises]] @@ -578,6 +589,16 @@ For example: Some(Some(variable)) = variable2 Also see Option::flatten """ +[[exercises]] +name = "option3" +path = "exercises/option/option3.rs" +mode = "compile" +hint = """ +The compiler says a partial move happened in the `match` +statement. How can this be avoided? The compiler shows the correction +needed. After making the correction as suggested by the compiler, do +read: https://doc.rust-lang.org/std/keyword.ref.html""" + [[exercises]] name = "result1" path = "exercises/error_handling/result1.rs" From cd02abc48138f9415d1d81da86524508d501a09f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 17 May 2021 12:11:04 +0000 Subject: [PATCH 6/7] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fede672..503cf2c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-92-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-93-orange.svg?style=flat-square)](#contributors-) # rustlings 🦀❤️ @@ -280,6 +280,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Brandon Macer

🖋
Stoian Dan

🖋
Pi Delport

🖋 +
Sateesh

💻 🖋 From 72e615aa7ae36c0e0a7c82b3e22a33a04f579e3c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 17 May 2021 12:11:05 +0000 Subject: [PATCH 7/7] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4627e29..867f1d5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -856,6 +856,16 @@ "contributions": [ "content" ] + }, + { + "login": "sateeshkumarb", + "name": "Sateesh ", + "avatar_url": "https://avatars.githubusercontent.com/u/429263?v=4", + "profile": "https://github.com/sateeshkumarb", + "contributions": [ + "code", + "content" + ] } ], "contributorsPerLine": 8,