Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitff33a66

Browse files
committed
regression test for leaks in the the Filter::next_chunk implementation
previously next_chunk would forget items rejected by the filter
1 parentf90972a commitff33a66

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎core/tests/iter/adapters/filter.rs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use core::iter::*;
2+
use std::rc::Rc;
23

34
#[test]
45
fntest_iterator_filter_count(){
@@ -50,3 +51,15 @@ fn test_double_ended_filter() {
5051
assert_eq!(it.next().unwrap(),&2);
5152
assert_eq!(it.next_back(),None);
5253
}
54+
55+
#[test]
56+
fntest_next_chunk_does_not_leak(){
57+
let drop_witness:[_;5] = std::array::from_fn(|_|Rc::new(()));
58+
59+
let v =(0..5).map(|i| drop_witness[i].clone()).collect::<Vec<_>>();
60+
let _ = v.into_iter().filter(|_|false).next_chunk::<1>();
61+
62+
forref win drop_witness{
63+
assert_eq!(Rc::strong_count(w),1);
64+
}
65+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp