You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all thank you for this project. It was really fun solving it so far. I got really stuck and scratching my head at this one and I decided to ask you for an improvement.
fnsimple_option(){let target = "rustlings";let optional_target = Some(target);// TODO: Make this an if let statement whose value is "Some" type
word = optional_target{
assert_eq!(word, target);}}
Looks like this excercise is trying to show how to use Option<T> type in Rust. Currently, the exercise seems somewhat forced and does not effectively demonstrate the real-world use cases of the Option type.
We start with a "rustlings" string literal and wrap it in optional_target. Then the comment asks us to Make this an if let statement whose value is "Some" type (which is a riddle by itself) providing us with some convoluted assertion. I am just learning Rust and have never seen this type before. If that task had some real-world scenario showing us why Option type is useful (for example safe parsing of data) that would really help.
The text was updated successfully, but these errors were encountered:
I agree this part of the exercise is weird. Do you have an idea how to improve it? We should still teach about the if-let statement though. You are welcome to open a PR :D
One problem is that it kind of looks like valid code. Coming from C++, Rust has some "weird" expressions (e.g. let ... else ... ;"). So when I first saw that code, my first thought was "what kind of Rust specific expression is that?", instead of "something is missing".
More specifically, it looks like a "normal" assignment where the rhs is optional_target{...} and so my thoughts weres like "are we creating a sort of a struct value of type optional_target?" and "are we creating a closure-like thing?".
Hello Rustlings Team,
First of all thank you for this project. It was really fun solving it so far. I got really stuck and scratching my head at this one and I decided to ask you for an improvement.
Looks like this excercise is trying to show how to use
Option<T>
type in Rust. Currently, the exercise seems somewhat forced and does not effectively demonstrate the real-world use cases of the Option type.We start with a "rustlings" string literal and wrap it in optional_target. Then the comment asks us to
Make this an if let statement whose value is "Some" type
(which is a riddle by itself) providing us with some convoluted assertion. I am just learning Rust and have never seen this type before. If that task had some real-world scenario showing us why Option type is useful (for example safe parsing of data) that would really help.The text was updated successfully, but these errors were encountered: