about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorblake2-ppc <blake2-ppc>2013-07-30 00:31:44 +0200
committerblake2-ppc <blake2-ppc>2013-07-30 01:48:17 +0200
commit2ff84124f0d39b20f49ce04f71d31322cdf1a327 (patch)
tree167d75f4d00f782f6cb2d6d9e0bb1b690f07946c /src/libstd
parent66fccdb2958fef88e00236497aec5e0f99fe7d02 (diff)
downloadrust-2ff84124f0d39b20f49ce04f71d31322cdf1a327.tar.gz
rust-2ff84124f0d39b20f49ce04f71d31322cdf1a327.zip
std: Remove RandomAccessIterator impl for VecMutIterator
The RandomAccessIterator implementation is not sound for the mutable vec
iterator, and makes it easy to duplicate &mut element pointers.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/vec.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index fdfe357ae51..ca752490faa 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -2106,7 +2106,8 @@ macro_rules! iterator {
 
             #[inline]
             fn size_hint(&self) -> (uint, Option<uint>) {
-                let exact = self.indexable();
+                let diff = (self.end as uint) - (self.ptr as uint);
+                let exact = diff / sys::nonzero_size_of::<T>();
                 (exact, Some(exact))
             }
         }
@@ -2139,8 +2140,8 @@ macro_rules! random_access_iterator {
         impl<'self, T> RandomAccessIterator<$elem> for $name<'self, T> {
             #[inline]
             fn indexable(&self) -> uint {
-                let diff = (self.end as uint) - (self.ptr as uint);
-                diff / sys::nonzero_size_of::<T>()
+                let (exact, _) = self.size_hint();
+                exact
             }
 
             fn idx(&self, index: uint) -> Option<$elem> {
@@ -2181,7 +2182,6 @@ pub struct VecMutIterator<'self, T> {
 }
 iterator!{impl VecMutIterator -> &'self mut T}
 double_ended_iterator!{impl VecMutIterator -> &'self mut T}
-random_access_iterator!{impl VecMutIterator -> &'self mut T}
 pub type MutRevIterator<'self, T> = Invert<VecMutIterator<'self, T>>;
 
 /// An iterator that moves out of a vector.