diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2014-03-04 18:52:26 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2014-03-04 18:53:57 -0500 |
| commit | 4d8295df6c7b6efa7ce27f2b59e30faf3028bf54 (patch) | |
| tree | d7e7bb88a810b6451225e07d9218dbaa99deabde /src/libstd/vec.rs | |
| parent | 6e7f170fedd3c526a643c0b2d13863acd982be02 (diff) | |
| download | rust-4d8295df6c7b6efa7ce27f2b59e30faf3028bf54.tar.gz rust-4d8295df6c7b6efa7ce27f2b59e30faf3028bf54.zip | |
make `MutItems` iterator sound again
This become `Pod` when it was switched to using marker types.
Diffstat (limited to 'src/libstd/vec.rs')
| -rw-r--r-- | src/libstd/vec.rs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 6a4f1871b86..59136c99ec9 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2311,11 +2311,13 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] { if mem::size_of::<T>() == 0 { MutItems{ptr: p, end: (p as uint + self.len()) as *mut T, - marker: marker::ContravariantLifetime::<'a>} + marker: marker::ContravariantLifetime::<'a>, + marker2: marker::NoPod} } else { MutItems{ptr: p, end: p.offset(self.len() as int), - marker: marker::ContravariantLifetime::<'a>} + marker: marker::ContravariantLifetime::<'a>, + marker2: marker::NoPod} } } } @@ -2682,15 +2684,23 @@ impl<A> Default for ~[A] { fn default() -> ~[A] { ~[] } } +/// Immutable slice iterator +pub struct Items<'a, T> { + priv ptr: *T, + priv end: *T, + priv marker: marker::ContravariantLifetime<'a> +} + +/// Mutable slice iterator +pub struct MutItems<'a, T> { + priv ptr: *mut T, + priv end: *mut T, + priv marker: marker::ContravariantLifetime<'a>, + priv marker2: marker::NoPod +} + macro_rules! iterator { (struct $name:ident -> $ptr:ty, $elem:ty) => { - /// An iterator for iterating over a vector. - pub struct $name<'a, T> { - priv ptr: $ptr, - priv end: $ptr, - priv marker: marker::ContravariantLifetime<'a>, - } - impl<'a, T> Iterator<$elem> for $name<'a, T> { #[inline] fn next(&mut self) -> Option<$elem> { |
