std/extra: Add ExactSize for Bitv, DList, RingBuf, Option iterators
This commit is contained in:
parent
35040dfccc
commit
7c369ee733
4 changed files with 12 additions and 1 deletions
|
|
@ -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>]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue