Fallout: Port slice to use PhantomData instead of ContravariantLifetime

This commit is contained in:
Niko Matsakis 2015-02-12 12:34:04 -05:00
parent 60f507be45
commit aaf4176f0f

View File

@ -140,11 +140,11 @@ impl<T> SliceExt for [T] {
if mem::size_of::<T>() == 0 { if mem::size_of::<T>() == 0 {
Iter {ptr: p, Iter {ptr: p,
end: (p as usize + self.len()) as *const T, end: (p as usize + self.len()) as *const T,
marker: marker::ContravariantLifetime::<'a>} _marker: marker::PhantomData}
} else { } else {
Iter {ptr: p, Iter {ptr: p,
end: p.offset(self.len() as isize), end: p.offset(self.len() as isize),
marker: marker::ContravariantLifetime::<'a>} _marker: marker::PhantomData}
} }
} }
} }
@ -279,11 +279,11 @@ impl<T> SliceExt for [T] {
if mem::size_of::<T>() == 0 { if mem::size_of::<T>() == 0 {
IterMut {ptr: p, IterMut {ptr: p,
end: (p as usize + self.len()) as *mut T, end: (p as usize + self.len()) as *mut T,
marker: marker::ContravariantLifetime::<'a>} _marker: marker::PhantomData}
} else { } else {
IterMut {ptr: p, IterMut {ptr: p,
end: p.offset(self.len() as isize), end: p.offset(self.len() as isize),
marker: marker::ContravariantLifetime::<'a>} _marker: marker::PhantomData}
} }
} }
} }
@ -733,7 +733,7 @@ macro_rules! make_slice {
pub struct Iter<'a, T: 'a> { pub struct Iter<'a, T: 'a> {
ptr: *const T, ptr: *const T,
end: *const T, end: *const T,
marker: marker::ContravariantLifetime<'a> _marker: marker::PhantomData<&'a T>,
} }
#[unstable(feature = "core")] #[unstable(feature = "core")]
@ -790,7 +790,7 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Iter<'a, T> { impl<'a, T> Clone for Iter<'a, T> {
fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, marker: self.marker } } fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } }
} }
#[unstable(feature = "core", reason = "trait is experimental")] #[unstable(feature = "core", reason = "trait is experimental")]
@ -823,7 +823,7 @@ impl<'a, T> RandomAccessIterator for Iter<'a, T> {
pub struct IterMut<'a, T: 'a> { pub struct IterMut<'a, T: 'a> {
ptr: *mut T, ptr: *mut T,
end: *mut T, end: *mut T,
marker: marker::ContravariantLifetime<'a>, _marker: marker::PhantomData<&'a mut T>,
} }