Skip to content

Commit 8666006

Browse files
committed
Clarify options2 exercise comments
1 parent 5e7a5d1 commit 8666006

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

exercises/12_options/options2.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ mod tests {
99
let target = "rustlings";
1010
let optional_target = Some(target);
1111

12-
// TODO: Make this an if-let statement whose value is `Some`.
12+
// TODO: Use an if-let statement to bind the value inside
13+
// `optional_target` to `word`.
1314
word = optional_target {
1415
assert_eq!(word, target);
1516
}
@@ -26,9 +27,16 @@ mod tests {
2627

2728
let mut cursor = range;
2829

29-
// TODO: Make this a while-let statement. Remember that `Vec::pop()`
30-
// adds another layer of `Option`. You can do nested pattern matching
31-
// in if-let and while-let statements.
30+
// TODO: Make this a while-let statement. The loop should keep popping
31+
// integers from the end of the vector until there is no integer left to
32+
// check.
33+
//
34+
// `Vec::pop()` removes the last element from the vector and returns it,
35+
// or returns `None` if the vector is empty. Since this vector stores
36+
// `Option<i8>` values, a successful pop returns the vector's inner
37+
// `Option<i8>` wrapped in another `Option`.
38+
// You can use nested pattern matching in if-let and while-let
39+
// statements.
3240
integer = optional_integers.pop() {
3341
assert_eq!(integer, cursor);
3442
cursor -= 1;

0 commit comments

Comments
 (0)