about summary refs log tree commit diff
diff options
context:
space:
mode:
authorblake2-ppc <blake2-ppc>2013-09-01 18:20:24 +0200
committerblake2-ppc <blake2-ppc>2013-09-01 18:20:24 +0200
commit7c369ee7337cee50f8ef05b9d2833e2aa30d802e (patch)
treef23d4238ab36002ed0274f775a9c27af2e15b68d
parent35040dfccc6674e8eda71b34a8cd1b4cc1b45842 (diff)
downloadrust-7c369ee7337cee50f8ef05b9d2833e2aa30d802e.tar.gz
rust-7c369ee7337cee50f8ef05b9d2833e2aa30d802e.zip
std/extra: Add ExactSize for Bitv, DList, RingBuf, Option iterators
-rw-r--r--src/libextra/bitv.rs2
-rw-r--r--src/libextra/dlist.rs3
-rw-r--r--src/libextra/ringbuf.rs4
-rw-r--r--src/libstd/option.rs4
4 files changed, 12 insertions, 1 deletions
diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs
index 63d62bd4809..03588d984d9 100644
--- a/src/libextra/bitv.rs
+++ b/src/libextra/bitv.rs
@@ -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 {
diff --git a/src/libextra/dlist.rs b/src/libextra/dlist.rs
index 8e641073637..075a0fa7777 100644
--- a/src/libextra/dlist.rs
+++ b/src/libextra/dlist.rs
@@ -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> {
diff --git a/src/libextra/ringbuf.rs b/src/libextra/ringbuf.rs
index 4f2755374af..9ae9b47e207 100644
--- a/src/libextra/ringbuf.rs
+++ b/src/libextra/ringbuf.rs
@@ -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>]) {
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index f99a595f2eb..dd66630187d 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -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::*;