@@ -56,24 +56,23 @@ impl<K, V> BTreeMap<K, V> {
56
56
assert ! ( root_node. ascend( ) . is_err( ) ) ;
57
57
root_node. assert_back_pointers ( ) ;
58
58
59
- // Check consistenty of `length` and some of the navigation .
59
+ // Check consistency of `length` with what navigation code encounters .
60
60
assert_eq ! ( self . length, root_node. calc_length( ) ) ;
61
- assert_eq ! ( self . length, self . keys( ) . count( ) ) ;
62
61
63
62
// Lastly, check the invariant causing the least harm.
64
63
root_node. assert_min_len ( if root_node. height ( ) > 0 { 1 } else { 0 } ) ;
65
64
} else {
66
- // Check consistenty of `length` and some of the navigation.
67
65
assert_eq ! ( self . length, 0 ) ;
68
- assert_eq ! ( self . length, self . keys( ) . count( ) ) ;
69
66
}
67
+
68
+ // Check that `assert_strictly_ascending` will encounter all keys.
69
+ assert_eq ! ( self . length, self . keys( ) . count( ) ) ;
70
70
}
71
71
72
72
// Panics if the map is corrupted or if the keys are not in strictly
73
73
// ascending order, in the current opinion of the `Ord` implementation.
74
- // If the `Ord` implementation does not honor transitivity, this method
75
- // does not guarantee that all the keys are unique, just that adjacent
76
- // keys are unique.
74
+ // If the `Ord` implementation violates transitivity, this method does not
75
+ // guarantee that all keys are unique, just that adjacent keys are unique.
77
76
fn check ( & self )
78
77
where
79
78
K : Debug + Ord ,
@@ -879,6 +878,7 @@ mod test_drain_filter {
879
878
map. check ( ) ;
880
879
}
881
880
881
+ // Explicitly consumes the iterator, where most test cases drop it instantly.
882
882
#[ test]
883
883
fn consumed_keeping_all ( ) {
884
884
let pairs = ( 0 ..3 ) . map ( |i| ( i, i) ) ;
@@ -887,6 +887,7 @@ mod test_drain_filter {
887
887
map. check ( ) ;
888
888
}
889
889
890
+ // Explicitly consumes the iterator, where most test cases drop it instantly.
890
891
#[ test]
891
892
fn consumed_removing_all ( ) {
892
893
let pairs = ( 0 ..3 ) . map ( |i| ( i, i) ) ;
@@ -896,15 +897,7 @@ mod test_drain_filter {
896
897
map. check ( ) ;
897
898
}
898
899
899
- #[ test]
900
- fn dropped_removing_all ( ) {
901
- let pairs = ( 0 ..3 ) . map ( |i| ( i, i) ) ;
902
- let mut map: BTreeMap < _ , _ > = pairs. collect ( ) ;
903
- map. drain_filter ( |_, _| true ) ;
904
- assert ! ( map. is_empty( ) ) ;
905
- map. check ( ) ;
906
- }
907
-
900
+ // Explicitly consumes the iterator and modifies values through it.
908
901
#[ test]
909
902
fn mutating_and_keeping ( ) {
910
903
let pairs = ( 0 ..3 ) . map ( |i| ( i, i) ) ;
@@ -921,6 +914,7 @@ mod test_drain_filter {
921
914
map. check ( ) ;
922
915
}
923
916
917
+ // Explicitly consumes the iterator and modifies values through it.
924
918
#[ test]
925
919
fn mutating_and_removing ( ) {
926
920
let pairs = ( 0 ..3 ) . map ( |i| ( i, i) ) ;
0 commit comments