Skip to content

Commit a7a4191

Browse files
committed
Add ExactSizeIterator implementation to Chain
1 parent c25473f commit a7a4191

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/core/src/iter/adapters/chain.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ where
273273
{
274274
}
275275

276+
impl<A, B> ExactSizeIterator for Chain<A, B>
277+
where
278+
A: ExactSizeIterator,
279+
B: ExactSizeIterator,
280+
{
281+
fn len(&self) -> usize {
282+
self.a.len() + self.b.len()
283+
}
284+
}
285+
276286
#[stable(feature = "default_iters", since = "1.70.0")]
277287
impl<A: Default, B: Default> Default for Chain<A, B> {
278288
/// Creates a `Chain` from the default values for `A` and `B`.

0 commit comments

Comments
 (0)