Skip to content

Commit 5d4af58

Browse files
author
blake2-ppc
committed
iterator: implement size_hint() for FlatMap
1 parent 4b2931c commit 5d4af58

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/iterator.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,16 @@ impl<'self, A, T: Iterator<A>, B, U: Iterator<B>> Iterator<B> for
12711271
}
12721272
}
12731273
}
1274+
1275+
#[inline]
1276+
fn size_hint(&self) -> (uint, Option<uint>) {
1277+
let (flo, fhi) = self.frontiter.map_default((0, Some(0)), |it| it.size_hint());
1278+
let (blo, bhi) = self.backiter.map_default((0, Some(0)), |it| it.size_hint());
1279+
match (self.iter.size_hint(), fhi, bhi) {
1280+
((0, Some(0)), Some(a), Some(b)) => (flo + blo, Some(a + b)),
1281+
_ => (flo + blo, None)
1282+
}
1283+
}
12741284
}
12751285

12761286
impl<'self,

0 commit comments

Comments
 (0)