Skip to content

Commit 7c369ee

Browse files
author
blake2-ppc
committed
std/extra: Add ExactSize for Bitv, DList, RingBuf, Option iterators
1 parent 35040df commit 7c369ee

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/libextra/bitv.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ impl<'self> DoubleEndedIterator<bool> for BitvIterator<'self> {
608608
}
609609
}
610610

611+
impl<'self> ExactSize<bool> for BitvIterator<'self> {}
612+
611613
impl<'self> RandomAccessIterator<bool> for BitvIterator<'self> {
612614
#[inline]
613615
fn indexable(&self) -> uint {

src/libextra/dlist.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ impl<'self, A> DoubleEndedIterator<&'self A> for DListIterator<'self, A> {
472472
}
473473
}
474474

475+
impl<'self, A> ExactSize<&'self A> for DListIterator<'self, A> {}
476+
475477
impl<'self, A> Iterator<&'self mut A> for MutDListIterator<'self, A> {
476478
#[inline]
477479
fn next(&mut self) -> Option<&'self mut A> {
@@ -508,6 +510,7 @@ impl<'self, A> DoubleEndedIterator<&'self mut A> for MutDListIterator<'self, A>
508510
}
509511
}
510512

513+
impl<'self, A> ExactSize<&'self mut A> for MutDListIterator<'self, A> {}
511514

512515
/// Allow mutating the DList while iterating
513516
pub trait ListInsertion<A> {

src/libextra/ringbuf.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ pub struct RingBufIterator<'self, T> {
243243
iterator!{impl RingBufIterator -> &'self T, get_ref}
244244
iterator_rev!{impl RingBufIterator -> &'self T, get_ref}
245245

246+
impl<'self, T> ExactSize<&'self T> for RingBufIterator<'self, T> {}
247+
246248
impl<'self, T> RandomAccessIterator<&'self T> for RingBufIterator<'self, T> {
247249
#[inline]
248250
fn indexable(&self) -> uint { self.rindex - self.index }
@@ -268,6 +270,8 @@ pub struct RingBufMutIterator<'self, T> {
268270
iterator!{impl RingBufMutIterator -> &'self mut T, get_mut_ref}
269271
iterator_rev!{impl RingBufMutIterator -> &'self mut T, get_mut_ref}
270272

273+
impl<'self, T> ExactSize<&'self mut T> for RingBufMutIterator<'self, T> {}
274+
271275
/// Grow is only called on full elts, so nelts is also len(elts), unlike
272276
/// elsewhere.
273277
fn grow<T>(nelts: uint, loptr: &mut uint, elts: &mut ~[Option<T>]) {

src/libstd/option.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use cmp::{Eq,Ord};
4646
use util;
4747
use num::Zero;
4848
use iterator;
49-
use iterator::{Iterator, DoubleEndedIterator};
49+
use iterator::{Iterator, DoubleEndedIterator, ExactSize};
5050
use str::{StrSlice, OwnedStr};
5151
use to_str::ToStr;
5252
use clone::DeepClone;
@@ -402,6 +402,8 @@ impl<A> DoubleEndedIterator<A> for OptionIterator<A> {
402402
}
403403
}
404404

405+
impl<A> ExactSize<A> for OptionIterator<A> {}
406+
405407
#[cfg(test)]
406408
mod tests {
407409
use super::*;

0 commit comments

Comments
 (0)