Merge pull request #1487 from lionel-rowe/patch-1
feat(options2): better test for layered_option
This commit is contained in:
commit
81cd97902a
@ -18,17 +18,22 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn layered_option() {
|
||||
let mut range = 10;
|
||||
let mut optional_integers: Vec<Option<i8>> = Vec::new();
|
||||
for i in 0..(range + 1) {
|
||||
let range = 10;
|
||||
let mut optional_integers: Vec<Option<i8>> = vec![None];
|
||||
|
||||
for i in 1..(range + 1) {
|
||||
optional_integers.push(Some(i));
|
||||
}
|
||||
|
||||
let mut cursor = range;
|
||||
|
||||
// TODO: make this a while let statement - remember that vector.pop also adds another layer of Option<T>
|
||||
// You can stack `Option<T>`'s into while let and if let
|
||||
// You can stack `Option<T>`s into while let and if let
|
||||
integer = optional_integers.pop() {
|
||||
assert_eq!(integer, range);
|
||||
range -= 1;
|
||||
}
|
||||
assert_eq!(integer, cursor);
|
||||
cursor -= 1;
|
||||
}
|
||||
|
||||
assert_eq!(cursor, 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user