File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
alloc/src/collections/btree/map Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -968,6 +968,30 @@ mod test_extract_if {
968
968
map. check ( ) ;
969
969
}
970
970
971
+ #[ test]
972
+ fn consumed_removing_some ( ) {
973
+ let pairs = ( 0 ..3 ) . map ( |i| ( i, i) ) ;
974
+ let map = BTreeMap :: from_iter ( pairs) ;
975
+ for x in 0 ..3 {
976
+ for y in 0 ..3 {
977
+ let mut map = map. clone ( ) ;
978
+ assert ! ( map. extract_if( x..y, |_, _| true ) . eq( ( x..y) . map( |i| ( i, i) ) ) ) ;
979
+ for i in 0 ..3 {
980
+ assert_ne ! ( map. contains_key( & i) , ( x..y) . contains( & i) ) ;
981
+ }
982
+ }
983
+ }
984
+ for x in 0 ..3 {
985
+ for y in 0 ..2 {
986
+ let mut map = map. clone ( ) ;
987
+ assert ! ( map. extract_if( x..=y, |_, _| true ) . eq( ( x..=y) . map( |i| ( i, i) ) ) ) ;
988
+ for i in 0 ..3 {
989
+ assert_ne ! ( map. contains_key( & i) , ( x..=y) . contains( & i) ) ;
990
+ }
991
+ }
992
+ }
993
+ }
994
+
971
995
// Explicitly consumes the iterator and modifies values through it.
972
996
#[ test]
973
997
fn mutating_and_keeping ( ) {
You can’t perform that action at this time.
0 commit comments