Skip to content

Commit 0cd6466

Browse files
committed
Let Flatten work with unsized iterators
1 parent 321a6c8 commit 0cd6466

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ pub trait StreamingIteratorMut: StreamingIterator {
598598
fn flatten(self) -> Flatten<Self>
599599
where
600600
Self: Sized,
601-
Self::Item: StreamingIterator + Sized,
601+
Self::Item: StreamingIterator,
602602
{
603603
Flatten {
604604
iter: self,
@@ -2599,6 +2599,20 @@ mod test {
25992599
test(it, &[1, 2, 3]);
26002600
}
26012601

2602+
#[test]
2603+
fn flatten_unsized() {
2604+
type DynI32 = dyn StreamingIterator<Item = i32>;
2605+
let mut items = [
2606+
&mut once(1) as &mut DynI32,
2607+
&mut empty(),
2608+
&mut convert(2..=3),
2609+
];
2610+
let iters = items.iter_mut().map(|iter| &mut **iter);
2611+
let it = convert_mut(iters).flatten();
2612+
2613+
test(it, &[1, 2, 3]);
2614+
}
2615+
26022616
#[test]
26032617
fn nth() {
26042618
let items = [0, 1];

0 commit comments

Comments
 (0)