We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f90972a commit ff33a66Copy full SHA for ff33a66
core/tests/iter/adapters/filter.rs
@@ -1,4 +1,5 @@
1
use core::iter::*;
2
+use std::rc::Rc;
3
4
#[test]
5
fn test_iterator_filter_count() {
@@ -50,3 +51,15 @@ fn test_double_ended_filter() {
50
51
assert_eq!(it.next().unwrap(), &2);
52
assert_eq!(it.next_back(), None);
53
}
54
+
55
+#[test]
56
+fn test_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
+ for ref w in drop_witness {
63
+ assert_eq!(Rc::strong_count(w), 1);
64
+ }
65
+}
0 commit comments