Skip to content

Commit 53d46ae

Browse files
committed
Add drain_filter_unconsumed test
1 parent 17a517a commit 53d46ae

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/liballoc/tests/vec.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,14 @@ fn drain_filter_unconsumed_panic() {
10441044
}
10451045
}
10461046

1047+
#[test]
1048+
fn drain_filter_unconsumed() {
1049+
let mut vec = vec![1, 2, 3, 4];
1050+
let drain = vec.drain_filter(|&mut x| x % 2 != 0);
1051+
drop(drain);
1052+
assert_eq!(vec, [2, 4]);
1053+
}
1054+
10471055
#[test]
10481056
fn test_reserve_exact() {
10491057
// This is all the same as test_reserve

0 commit comments

Comments
 (0)