@@ -1,4 +1,5 @@ |
|
|
1 |
1 |
use core::iter::*; |
|
2 |
+use std::rc::Rc; |
2 |
3 |
|
3 |
4 |
#[test] |
4 |
5 |
fn test_iterator_filter_count() { |
@@ -50,3 +51,15 @@ fn test_double_ended_filter() { |
|
|
50 |
51 |
assert_eq!(it.next().unwrap(), &2); |
51 |
52 |
assert_eq!(it.next_back(), None); |
52 |
53 |
} |
|
54 |
+ |
|
55 |
+#[test] |
|
56 |
+fn test_next_chunk_does_not_leak() { |
|
57 |
+let drop_witness: [_; 5] = std::array::from_fn(|_ |
|
58 |
+ |
|
59 |
+let v = (0..5).map(|i |
|
60 |
+let _ = v.into_iter().filter(|_ |
|
61 |
+ |
|
62 |
+for ref w in drop_witness { |
|
63 |
+assert_eq!(Rc::strong_count(w), 1); |
|
64 |
+} |
|
65 |
+} |