Skip to content

Commit 2d99e16

Browse files
committed
fix implmentations of ExactSizeIterator::len()
1 parent d2e5181 commit 2d99e16

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

capnp/src/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<U, T: IndexMove<u32, U>> ::core::iter::Iterator for ListIter<T, U> {
169169

170170
impl<U, T: IndexMove<u32, U>> ::core::iter::ExactSizeIterator for ListIter<T, U> {
171171
fn len(&self) -> usize {
172-
self.size as usize
172+
self.size as usize - self.index as usize
173173
}
174174
}
175175

@@ -234,7 +234,7 @@ impl<U, T: IndexMove<u16, U>> ::core::iter::Iterator for ShortListIter<T, U> {
234234

235235
impl<U, T: IndexMove<u16, U>> ::core::iter::ExactSizeIterator for ShortListIter<T, U> {
236236
fn len(&self) -> usize {
237-
self.size as usize
237+
self.size as usize - self.index as usize
238238
}
239239
}
240240

0 commit comments

Comments
 (0)