mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-07 10:13:31 +02:00
feat(options): completed options
This commit is contained in:
@@ -10,8 +10,12 @@ mod tests {
|
||||
let optional_target = Some(target);
|
||||
|
||||
// TODO: Make this an if-let statement whose value is `Some`.
|
||||
word = optional_target {
|
||||
assert_eq!(word, target);
|
||||
//
|
||||
// word = optional_target {
|
||||
// assert_eq!(word, target);
|
||||
// }
|
||||
if let Some(word) = optional_target {
|
||||
assert_eq!(word, target)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +33,13 @@ mod tests {
|
||||
// TODO: Make this a while-let statement. Remember that `Vec::pop()`
|
||||
// adds another layer of `Option`. You can do nested pattern matching
|
||||
// in if-let and while-let statements.
|
||||
integer = optional_integers.pop() {
|
||||
//
|
||||
// integer = optional_integers.pop() {
|
||||
// assert_eq!(integer, cursor);
|
||||
// cursor -= 1;
|
||||
// }
|
||||
|
||||
while let Some(Some(integer)) = optional_integers.pop() {
|
||||
assert_eq!(integer, cursor);
|
||||
cursor -= 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user