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