std/extra: Add ExactSize for Bitv, DList, RingBuf, Option iterators
This commit is contained in:
parent
35040dfccc
commit
7c369ee733
@ -608,6 +608,8 @@ impl<'self> DoubleEndedIterator<bool> for BitvIterator<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> ExactSize<bool> for BitvIterator<'self> {}
|
||||
|
||||
impl<'self> RandomAccessIterator<bool> for BitvIterator<'self> {
|
||||
#[inline]
|
||||
fn indexable(&self) -> uint {
|
||||
|
@ -472,6 +472,8 @@ impl<'self, A> DoubleEndedIterator<&'self A> for DListIterator<'self, A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, A> ExactSize<&'self A> for DListIterator<'self, A> {}
|
||||
|
||||
impl<'self, A> Iterator<&'self mut A> for MutDListIterator<'self, A> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'self mut A> {
|
||||
@ -508,6 +510,7 @@ impl<'self, A> DoubleEndedIterator<&'self mut A> for MutDListIterator<'self, A>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, A> ExactSize<&'self mut A> for MutDListIterator<'self, A> {}
|
||||
|
||||
/// Allow mutating the DList while iterating
|
||||
pub trait ListInsertion<A> {
|
||||
|
@ -243,6 +243,8 @@ pub struct RingBufIterator<'self, T> {
|
||||
iterator!{impl RingBufIterator -> &'self T, get_ref}
|
||||
iterator_rev!{impl RingBufIterator -> &'self T, get_ref}
|
||||
|
||||
impl<'self, T> ExactSize<&'self T> for RingBufIterator<'self, T> {}
|
||||
|
||||
impl<'self, T> RandomAccessIterator<&'self T> for RingBufIterator<'self, T> {
|
||||
#[inline]
|
||||
fn indexable(&self) -> uint { self.rindex - self.index }
|
||||
@ -268,6 +270,8 @@ pub struct RingBufMutIterator<'self, T> {
|
||||
iterator!{impl RingBufMutIterator -> &'self mut T, get_mut_ref}
|
||||
iterator_rev!{impl RingBufMutIterator -> &'self mut T, get_mut_ref}
|
||||
|
||||
impl<'self, T> ExactSize<&'self mut T> for RingBufMutIterator<'self, T> {}
|
||||
|
||||
/// Grow is only called on full elts, so nelts is also len(elts), unlike
|
||||
/// elsewhere.
|
||||
fn grow<T>(nelts: uint, loptr: &mut uint, elts: &mut ~[Option<T>]) {
|
||||
|
@ -46,7 +46,7 @@ use cmp::{Eq,Ord};
|
||||
use util;
|
||||
use num::Zero;
|
||||
use iterator;
|
||||
use iterator::{Iterator, DoubleEndedIterator};
|
||||
use iterator::{Iterator, DoubleEndedIterator, ExactSize};
|
||||
use str::{StrSlice, OwnedStr};
|
||||
use to_str::ToStr;
|
||||
use clone::DeepClone;
|
||||
@ -402,6 +402,8 @@ impl<A> DoubleEndedIterator<A> for OptionIterator<A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A> ExactSize<A> for OptionIterator<A> {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user