diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-10-05 12:22:42 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-10-07 15:49:53 +1300 |
| commit | cd21e4a72c0175d226acc837d1886cfdfa40fe68 (patch) | |
| tree | b9860886daf57e5ce87e8863208e4ab0a3e947bb /src/libcore | |
| parent | 2d3823441fe5324f747f7bf51ffc07b9434f827f (diff) | |
| download | rust-cd21e4a72c0175d226acc837d1886cfdfa40fe68.tar.gz rust-cd21e4a72c0175d226acc837d1886cfdfa40fe68.zip | |
Rename slice::Slice
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/fmt/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/option.rs | 16 | ||||
| -rw-r--r-- | src/libcore/prelude.rs | 3 | ||||
| -rw-r--r-- | src/libcore/result.rs | 21 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 8 |
5 files changed, 6 insertions, 44 deletions
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 28ee522346f..093f5896aad 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -22,7 +22,7 @@ use option::{Option, Some, None}; use ops::Deref; use result::{Ok, Err}; use result; -use slice::{Slice, ImmutableSlice}; +use slice::{AsSlice, ImmutableSlice}; use slice; use str::StrSlice; use str; diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 1e353708730..ec7d655b087 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -149,7 +149,6 @@ use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize}; use mem; use result::{Result, Ok, Err}; use slice; -use slice::Slice; // Note that this is not a lang item per se, but it has a hidden dependency on // `Iterator`, which is one. The compiler assumes that the `next` method of @@ -846,21 +845,6 @@ impl<T: Default> Option<T> { // Trait implementations ///////////////////////////////////////////////////////////////////////////// -impl<T> Slice<T> for Option<T> { - /// Convert from `Option<T>` to `&[T]` (without copying) - #[inline] - #[stable] - fn as_slice<'a>(&'a self) -> &'a [T] { - match *self { - Some(ref x) => slice::ref_slice(x), - None => { - let result: &[_] = &[]; - result - } - } - } -} - impl<T> Default for Option<T> { #[inline] fn default() -> Option<T> { None } diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index ead48092c4d..da17b113bf4 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -62,5 +62,4 @@ pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4}; pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8}; pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12}; pub use slice::{ImmutablePartialEqSlice, ImmutableOrdSlice}; -pub use slice::{MutableSlice}; -pub use slice::{Slice, ImmutableSlice}; +pub use slice::{AsSlice, ImmutableSlice, MutableSlice}; diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 9f347aacedc..f734ee8d0cb 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -280,7 +280,6 @@ use clone::Clone; use cmp::PartialEq; use std::fmt::Show; use slice; -use slice::Slice; use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize}; use option::{None, Option, Some}; @@ -841,26 +840,6 @@ impl<T: Show, E> Result<T, E> { } ///////////////////////////////////////////////////////////////////////////// -// Trait implementations -///////////////////////////////////////////////////////////////////////////// - -impl<T, E> Slice<T> for Result<T, E> { - /// Convert from `Result<T, E>` to `&[T]` (without copying) - #[inline] - #[stable] - fn as_slice<'a>(&'a self) -> &'a [T] { - match *self { - Ok(ref x) => slice::ref_slice(x), - Err(_) => { - // work around lack of implicit coercion from fixed-size array to slice - let emp: &[_] = &[]; - emp - } - } - } -} - -///////////////////////////////////////////////////////////////////////////// // The Result Iterator ///////////////////////////////////////////////////////////////////////////// diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index e1afd1a647a..67503751742 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1143,13 +1143,13 @@ impl<'a, T:Clone> MutableCloneableSlice<T> for &'a mut [T] { /// Data that is viewable as a slice. #[unstable = "may merge with other traits"] -pub trait Slice<T> { +pub trait AsSlice<T> { /// Work with `self` as a slice. fn as_slice<'a>(&'a self) -> &'a [T]; } #[unstable = "trait is unstable"] -impl<'a,T> Slice<T> for &'a [T] { +impl<'a,T> AsSlice<T> for &'a [T] { #[inline(always)] fn as_slice<'a>(&'a self) -> &'a [T] { *self } } @@ -1828,7 +1828,7 @@ impl<'a,T:PartialEq> PartialEq for &'a [T] { impl<'a,T:Eq> Eq for &'a [T] {} #[unstable = "waiting for DST"] -impl<'a,T:PartialEq, V: Slice<T>> Equiv<V> for &'a [T] { +impl<'a,T:PartialEq, V: AsSlice<T>> Equiv<V> for &'a [T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } } @@ -1849,7 +1849,7 @@ impl<'a,T:PartialEq> PartialEq for &'a mut [T] { impl<'a,T:Eq> Eq for &'a mut [T] {} #[unstable = "waiting for DST"] -impl<'a,T:PartialEq, V: Slice<T>> Equiv<V> for &'a mut [T] { +impl<'a,T:PartialEq, V: AsSlice<T>> Equiv<V> for &'a mut [T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } } |
