diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index ca752490faa..cfd28fcfc5e 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2135,23 +2135,19 @@ macro_rules! double_ended_iterator { } } -macro_rules! random_access_iterator { - (impl $name:ident -> $elem:ty) => { - impl<'self, T> RandomAccessIterator<$elem> for $name<'self, T> { - #[inline] - fn indexable(&self) -> uint { - let (exact, _) = self.size_hint(); - exact - } +impl<'self, T> RandomAccessIterator<&'self T> for VecIterator<'self, T> { + #[inline] + fn indexable(&self) -> uint { + let (exact, _) = self.size_hint(); + exact + } - fn idx(&self, index: uint) -> Option<$elem> { - unsafe { - if index < self.indexable() { - cast::transmute(self.ptr.offset(index)) - } else { - None - } - } + fn idx(&self, index: uint) -> Option<&'self T> { + unsafe { + if index < self.indexable() { + cast::transmute(self.ptr.offset(index)) + } else { + None } } } @@ -2166,7 +2162,6 @@ pub struct VecIterator<'self, T> { } iterator!{impl VecIterator -> &'self T} double_ended_iterator!{impl VecIterator -> &'self T} -random_access_iterator!{impl VecIterator -> &'self T} pub type RevIterator<'self, T> = Invert>; impl<'self, T> Clone for VecIterator<'self, T> {