diff options
| author | Brian Anderson <banderson@mozilla.com> | 2014-08-06 20:03:55 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2014-08-13 11:30:14 -0700 |
| commit | fbc93082ec92c3534c4b27fef35d78d97bd77fd2 (patch) | |
| tree | d5154fe0a4a461ce65f1dff659ac9117fb310e8d /src/libcore | |
| parent | 4f5b6927e8e428239082ecc17b85a0506bcc9a65 (diff) | |
| download | rust-fbc93082ec92c3534c4b27fef35d78d97bd77fd2.tar.gz rust-fbc93082ec92c3534c4b27fef35d78d97bd77fd2.zip | |
std: Rename slice::Vector to Slice
This required some contortions because importing both raw::Slice and slice::Slice makes rustc crash. Since `Slice` is in the prelude, this renaming is unlikely to casue breakage. [breaking-change]
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/fmt/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/option.rs | 4 | ||||
| -rw-r--r-- | src/libcore/prelude.rs | 2 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 26 |
4 files changed, 18 insertions, 16 deletions
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 61f0d09453f..942f7f8b710 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -24,7 +24,7 @@ use option::{Option, Some, None}; use ops::Deref; use result::{Ok, Err}; use result; -use slice::{Vector, ImmutableSlice}; +use slice::{Slice, ImmutableSlice}; use slice; use str::StrSlice; use str; diff --git a/src/libcore/option.rs b/src/libcore/option.rs index f8293aeb03d..74d87712a02 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -143,7 +143,7 @@ use cmp::{PartialEq, Eq, Ord}; use default::Default; -use slice::Vector; +use slice::Slice; use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize}; use mem; use slice; @@ -518,7 +518,7 @@ impl<T: Default> Option<T> { // Trait implementations ///////////////////////////////////////////////////////////////////////////// -impl<T> Vector<T> for Option<T> { +impl<T> Slice<T> for Option<T> { /// Convert from `Option<T>` to `&[T]` (without copying) #[inline] fn as_slice<'a>(&'a self) -> &'a [T] { diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 08a431b0d1f..2d5c9c0e960 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -63,4 +63,4 @@ pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8}; pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12}; pub use slice::{ImmutableEqSlice, ImmutableOrdSlice}; pub use slice::{MutableSlice}; -pub use slice::{Vector, ImmutableSlice}; +pub use slice::{Slice, ImmutableSlice}; diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 6c8bacaef48..3a619b45e53 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -47,7 +47,9 @@ use ptr::RawPtr; use mem; use mem::size_of; use kinds::marker; -use raw::{Repr, Slice}; +use raw::{Repr}; +// Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module. +use RawSlice = raw::Slice; // // Extension traits @@ -240,7 +242,7 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { assert!(start <= end); assert!(end <= self.len()); unsafe { - transmute(Slice { + transmute(RawSlice { data: self.as_ptr().offset(start as int), len: (end - start) }) @@ -380,7 +382,7 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { fn shift_ref(&mut self) -> Option<&'a T> { unsafe { - let s: &mut Slice<T> = transmute(self); + let s: &mut RawSlice<T> = transmute(self); match raw::shift_ptr(s) { Some(p) => Some(&*p), None => None @@ -390,7 +392,7 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { fn pop_ref(&mut self) -> Option<&'a T> { unsafe { - let s: &mut Slice<T> = transmute(self); + let s: &mut RawSlice<T> = transmute(self); match raw::pop_ptr(s) { Some(p) => Some(&*p), None => None @@ -620,7 +622,7 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { assert!(start <= end); assert!(end <= self.len()); unsafe { - transmute(Slice { + transmute(RawSlice { data: self.as_mut_ptr().offset(start as int) as *const T, len: (end - start) }) @@ -685,7 +687,7 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { fn mut_shift_ref(&mut self) -> Option<&'a mut T> { unsafe { - let s: &mut Slice<T> = transmute(self); + let s: &mut RawSlice<T> = transmute(self); match raw::shift_ptr(s) { // FIXME #13933: this `&` -> `&mut` cast is a little // dubious @@ -697,7 +699,7 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { fn mut_pop_ref(&mut self) -> Option<&'a mut T> { unsafe { - let s: &mut Slice<T> = transmute(self); + let s: &mut RawSlice<T> = transmute(self); match raw::pop_ptr(s) { // FIXME #13933: this `&` -> `&mut` cast is a little // dubious @@ -859,12 +861,12 @@ impl<'a, T:Clone> MutableCloneableSlice<T> for &'a mut [T] { // /// Any vector that can be represented as a slice. -pub trait Vector<T> { +pub trait Slice<T> { /// Work with `self` as a slice. fn as_slice<'a>(&'a self) -> &'a [T]; } -impl<'a,T> Vector<T> for &'a [T] { +impl<'a,T> Slice<T> for &'a [T] { #[inline(always)] fn as_slice<'a>(&'a self) -> &'a [T] { *self } } @@ -1323,7 +1325,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutChunks<'a, T> { */ pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] { unsafe { - transmute(Slice { data: s, len: 1 }) + transmute(RawSlice { data: s, len: 1 }) } } @@ -1333,7 +1335,7 @@ pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] { pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] { unsafe { let ptr: *const A = transmute(s); - transmute(Slice { data: ptr, len: 1 }) + transmute(RawSlice { data: ptr, len: 1 }) } } @@ -1460,7 +1462,7 @@ impl<'a,T:PartialEq> PartialEq for &'a [T] { impl<'a,T:Eq> Eq for &'a [T] {} -impl<'a,T:PartialEq, V: Vector<T>> Equiv<V> for &'a [T] { +impl<'a,T:PartialEq, V: Slice<T>> Equiv<V> for &'a [T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } } |
