diff options
| author | Florian Wilkens <floya@live.de> | 2014-12-19 21:52:10 +0100 |
|---|---|---|
| committer | Florian Wilkens <floya@live.de> | 2014-12-22 12:58:55 +0100 |
| commit | f8cfd2480b69a1cc266fc91d0b60c825a9dc18a7 (patch) | |
| tree | 6d0eff18d899f6a660797fa3fa4265fd59ad4ed7 /src/libcore | |
| parent | 34d680009205de2302b902d8f9f5f7ae7a042f1a (diff) | |
| download | rust-f8cfd2480b69a1cc266fc91d0b60c825a9dc18a7.tar.gz rust-f8cfd2480b69a1cc266fc91d0b60c825a9dc18a7.zip | |
Renaming of the Iter types as in RFC #344
libcore: slice::Items -> slice::Iter, slice::MutItems -> slice::IterMut libcollections: *::Items -> *::Iter, *::MoveItems -> *::IntoIter, *::MutItems -> *::IterMut This is of course a [breaking-change].
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/fmt/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 50 | ||||
| -rw-r--r-- | src/libcore/str.rs | 9 |
3 files changed, 30 insertions, 31 deletions
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 79fb11f3854..96f67ac4f7a 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -89,7 +89,7 @@ pub struct Formatter<'a> { precision: Option<uint>, buf: &'a mut (FormatWriter+'a), - curarg: slice::Items<'a, Argument<'a>>, + curarg: slice::Iter<'a, Argument<'a>>, args: &'a [Argument<'a>], } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index efc92429afd..6092a45c97d 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -67,7 +67,7 @@ pub trait SliceExt<T> for Sized? { fn slice_from<'a>(&'a self, start: uint) -> &'a [T]; fn slice_to<'a>(&'a self, end: uint) -> &'a [T]; fn split_at<'a>(&'a self, mid: uint) -> (&'a [T], &'a [T]); - fn iter<'a>(&'a self) -> Items<'a, T>; + fn iter<'a>(&'a self) -> Iter<'a, T>; fn split<'a, P>(&'a self, pred: P) -> Splits<'a, T, P> where P: FnMut(&T) -> bool; fn splitn<'a, P>(&'a self, n: uint, pred: P) -> SplitsN<Splits<'a, T, P>> @@ -92,7 +92,7 @@ pub trait SliceExt<T> for Sized? { fn slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T]; fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T]; fn slice_to_mut<'a>(&'a mut self, end: uint) -> &'a mut [T]; - fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T>; + fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T>; fn head_mut<'a>(&'a mut self) -> Option<&'a mut T>; fn tail_mut<'a>(&'a mut self) -> &'a mut [T]; fn init_mut<'a>(&'a mut self) -> &'a mut [T]; @@ -141,15 +141,15 @@ impl<T> SliceExt<T> for [T] { } #[inline] - fn iter<'a>(&'a self) -> Items<'a, T> { + fn iter<'a>(&'a self) -> Iter<'a, T> { unsafe { let p = self.as_ptr(); if mem::size_of::<T>() == 0 { - Items{ptr: p, + Iter{ptr: p, end: (p as uint + self.len()) as *const T, marker: marker::ContravariantLifetime::<'a>} } else { - Items{ptr: p, + Iter{ptr: p, end: p.offset(self.len() as int), marker: marker::ContravariantLifetime::<'a>} } @@ -286,15 +286,15 @@ impl<T> SliceExt<T> for [T] { } #[inline] - fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { + fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> { unsafe { let p = self.as_mut_ptr(); if mem::size_of::<T>() == 0 { - MutItems{ptr: p, + IterMut{ptr: p, end: (p as uint + self.len()) as *mut T, marker: marker::ContravariantLifetime::<'a>} } else { - MutItems{ptr: p, + IterMut{ptr: p, end: p.offset(self.len() as int), marker: marker::ContravariantLifetime::<'a>} } @@ -655,7 +655,7 @@ impl<'a, T> Default for &'a [T] { // Iterators // -// The shared definition of the `Item` and `MutItems` iterators +// The shared definition of the `Item` and `IterMut` iterators macro_rules! iterator { (struct $name:ident -> $ptr:ty, $elem:ty) => { #[experimental = "needs review"] @@ -738,14 +738,14 @@ macro_rules! make_slice { /// Immutable slice iterator #[experimental = "needs review"] -pub struct Items<'a, T: 'a> { +pub struct Iter<'a, T: 'a> { ptr: *const T, end: *const T, marker: marker::ContravariantLifetime<'a> } #[experimental] -impl<'a, T> ops::Slice<uint, [T]> for Items<'a, T> { +impl<'a, T> ops::Slice<uint, [T]> for Iter<'a, T> { fn as_slice_(&self) -> &[T] { self.as_slice() } @@ -763,7 +763,7 @@ impl<'a, T> ops::Slice<uint, [T]> for Items<'a, T> { } } -impl<'a, T> Items<'a, T> { +impl<'a, T> Iter<'a, T> { /// View the underlying data as a subslice of the original data. /// /// This has the same lifetime as the original slice, and so the @@ -774,20 +774,20 @@ impl<'a, T> Items<'a, T> { } } -impl<'a,T> Copy for Items<'a,T> {} +impl<'a,T> Copy for Iter<'a,T> {} -iterator!{struct Items -> *const T, &'a T} +iterator!{struct Iter -> *const T, &'a T} #[experimental = "needs review"] -impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {} +impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {} -#[stable] -impl<'a, T> Clone for Items<'a, T> { - fn clone(&self) -> Items<'a, T> { *self } + #[experimental = "needs review"] +impl<'a, T> Clone for Iter<'a, T> { + fn clone(&self) -> Iter<'a, T> { *self } } #[experimental = "needs review"] -impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { +impl<'a, T> RandomAccessIterator<&'a T> for Iter<'a, T> { #[inline] fn indexable(&self) -> uint { let (exact, _) = self.size_hint(); @@ -813,14 +813,14 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { /// Mutable slice iterator. #[experimental = "needs review"] -pub struct MutItems<'a, T: 'a> { +pub struct IterMut<'a, T: 'a> { ptr: *mut T, end: *mut T, marker: marker::ContravariantLifetime<'a>, } #[experimental] -impl<'a, T> ops::Slice<uint, [T]> for MutItems<'a, T> { +impl<'a, T> ops::Slice<uint, [T]> for IterMut<'a, T> { fn as_slice_<'b>(&'b self) -> &'b [T] { make_slice!(T -> &'b [T]: self.ptr, self.end) } @@ -839,7 +839,7 @@ impl<'a, T> ops::Slice<uint, [T]> for MutItems<'a, T> { } #[experimental] -impl<'a, T> ops::SliceMut<uint, [T]> for MutItems<'a, T> { +impl<'a, T> ops::SliceMut<uint, [T]> for IterMut<'a, T> { fn as_mut_slice_<'b>(&'b mut self) -> &'b mut [T] { make_slice!(T -> &'b mut [T]: self.ptr, self.end) } @@ -857,7 +857,7 @@ impl<'a, T> ops::SliceMut<uint, [T]> for MutItems<'a, T> { } } -impl<'a, T> MutItems<'a, T> { +impl<'a, T> IterMut<'a, T> { /// View the underlying data as a subslice of the original data. /// /// To avoid creating `&mut` references that alias, this is forced @@ -870,10 +870,10 @@ impl<'a, T> MutItems<'a, T> { } } -iterator!{struct MutItems -> *mut T, &'a mut T} +iterator!{struct IterMut -> *mut T, &'a mut T} #[experimental = "needs review"] -impl<'a, T> ExactSizeIterator<&'a mut T> for MutItems<'a, T> {} +impl<'a, T> ExactSizeIterator<&'a mut T> for IterMut<'a, T> {} /// An abstraction over the splitting iterators, so that splitn, splitn_mut etc /// can be implemented once. diff --git a/src/libcore/str.rs b/src/libcore/str.rs index a89a7970ae9..e147229bcbd 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -167,7 +167,7 @@ Section: Iterators /// Created with the method `.chars()`. #[deriving(Clone, Copy)] pub struct Chars<'a> { - iter: slice::Items<'a, u8> + iter: slice::Iter<'a, u8> } // Return the initial codepoint accumulator for the first byte. @@ -315,7 +315,7 @@ impl<'a> DoubleEndedIterator<(uint, char)> for CharOffsets<'a> { /// External iterator for a string's bytes. /// Use with the `std::iter` module. -pub type Bytes<'a> = Map<&'a u8, u8, slice::Items<'a, u8>, BytesFn>; +pub type Bytes<'a> = Map<&'a u8, u8, slice::Iter<'a, u8>, BytesFn>; /// A temporary new type wrapper that ensures that the `Bytes` iterator /// is cloneable. @@ -893,7 +893,7 @@ Section: Misc /// `iter` reset such that it is pointing at the first byte in the /// invalid sequence. #[inline(always)] -fn run_utf8_validation_iterator(iter: &mut slice::Items<u8>) -> bool { +fn run_utf8_validation_iterator(iter: &mut slice::Iter<u8>) -> bool { loop { // save the current thing we're pointing at. let old = *iter; @@ -993,7 +993,7 @@ pub fn is_utf16(v: &[u16]) -> bool { /// of `u16`s. #[deriving(Clone)] pub struct Utf16Items<'a> { - iter: slice::Items<'a, u16> + iter: slice::Iter<'a, u16> } /// The possibilities for values decoded from a `u16` stream. #[deriving(Copy, PartialEq, Eq, Clone, Show)] @@ -2366,4 +2366,3 @@ impl<'a> Default for &'a str { #[stable] fn default() -> &'a str { "" } } - |
