File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,22 @@ mod tests {
18
18
19
19
#[ test]
20
20
fn layered_option ( ) {
21
- let mut range = 10 ;
22
- let mut optional_integers: Vec < Option < i8 > > = Vec :: new ( ) ;
23
- for i in 0 ..( range + 1 ) {
21
+ let range = 10 ;
22
+ let mut optional_integers: Vec < Option < i8 > > = vec ! [ None ] ;
23
+
24
+ for i in 1 ..( range + 1 ) {
24
25
optional_integers. push ( Some ( i) ) ;
25
26
}
26
27
28
+ let mut cursor = range;
29
+
27
30
// TODO: make this a while let statement - remember that vector.pop also adds another layer of Option<T>
28
- // You can stack `Option<T>`' s into while let and if let
31
+ // You can stack `Option<T>`s into while let and if let
29
32
integer = optional_integers. pop ( ) {
30
- assert_eq ! ( integer, range ) ;
31
- range -= 1 ;
33
+ assert_eq ! ( integer, cursor ) ;
34
+ cursor -= 1 ;
32
35
}
36
+
37
+ assert_eq ! ( cursor, 0 ) ;
33
38
}
34
39
}
You can’t perform that action at this time.
0 commit comments