about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcollections/hash/sip.rs2
-rw-r--r--src/libcollections/slice.rs4
-rw-r--r--src/libcollections/str.rs4
-rw-r--r--src/libcollections/vec.rs6
-rw-r--r--src/libcore/fmt/mod.rs2
-rw-r--r--src/libcore/option.rs16
-rw-r--r--src/libcore/prelude.rs3
-rw-r--r--src/libcore/result.rs21
-rw-r--r--src/libcore/slice.rs8
-rw-r--r--src/libgraphviz/maybe_owned_vec.rs4
-rw-r--r--src/libstd/ascii.rs2
-rw-r--r--src/libstd/c_vec.rs4
-rw-r--r--src/libstd/dynamic_lib.rs2
-rw-r--r--src/libstd/io/extensions.rs2
-rw-r--r--src/libstd/io/mem.rs2
-rw-r--r--src/libstd/io/mod.rs2
-rw-r--r--src/libstd/os.rs2
-rw-r--r--src/libstd/path/mod.rs2
-rw-r--r--src/libstd/path/posix.rs4
-rw-r--r--src/libstd/path/windows.rs2
-rw-r--r--src/libstd/prelude.rs2
-rw-r--r--src/libsyntax/test.rs2
22 files changed, 30 insertions, 68 deletions
diff --git a/src/libcollections/hash/sip.rs b/src/libcollections/hash/sip.rs
index f3798e5f9e0..ab182bd5602 100644
--- a/src/libcollections/hash/sip.rs
+++ b/src/libcollections/hash/sip.rs
@@ -273,7 +273,7 @@ mod tests {
 
     use str::Str;
     use string::String;
-    use slice::{Slice, ImmutableSlice};
+    use slice::{AsSlice, ImmutableSlice};
     use vec::Vec;
 
     use super::super::{Hash, Writer};
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs
index 253375aabe8..e07f6dbd35d 100644
--- a/src/libcollections/slice.rs
+++ b/src/libcollections/slice.rs
@@ -98,7 +98,7 @@ use core::iter::{range_step, MultiplicativeIterator};
 use MutableSeq;
 use vec::Vec;
 
-pub use core::slice::{Chunks, Slice, ImmutableSlice, ImmutablePartialEqSlice};
+pub use core::slice::{Chunks, AsSlice, ImmutableSlice, ImmutablePartialEqSlice};
 pub use core::slice::{ImmutableOrdSlice, MutableSlice, Items, MutItems};
 pub use core::slice::{MutSplits, MutChunks, Splits};
 pub use core::slice::{bytes, mut_ref_slice, ref_slice, MutableCloneableSlice};
@@ -117,7 +117,7 @@ pub trait VectorVector<T> {
     fn connect_vec(&self, sep: &T) -> Vec<T>;
 }
 
-impl<'a, T: Clone, V: Slice<T>> VectorVector<T> for &'a [V] {
+impl<'a, T: Clone, V: AsSlice<T>> VectorVector<T> for &'a [V] {
     fn concat_vec(&self) -> Vec<T> {
         let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
         let mut result = Vec::with_capacity(size);
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index 3976367a76a..aabf5544954 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -61,7 +61,7 @@ use core::iter::AdditiveIterator;
 use core::mem;
 use core::prelude::{Char, Clone, Collection, Eq, Equiv, ImmutableSlice};
 use core::prelude::{Iterator, MutableSlice, None, Option, Ord, Ordering};
-use core::prelude::{PartialEq, PartialOrd, Result, Slice, Some, Tuple2};
+use core::prelude::{PartialEq, PartialOrd, Result, AsSlice, Some, Tuple2};
 use core::prelude::{range};
 
 use {Deque, MutableSeq};
@@ -880,7 +880,7 @@ mod tests {
     use {Collection, MutableSeq};
 
     use super::*;
-    use std::slice::{Slice, ImmutableSlice};
+    use std::slice::{AsSlice, ImmutableSlice};
     use string::String;
     use vec::Vec;
 
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 7b4cf4900f2..b995af952f1 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -547,7 +547,7 @@ impl<T: PartialOrd> PartialOrd for Vec<T> {
 impl<T: Eq> Eq for Vec<T> {}
 
 #[experimental]
-impl<T: PartialEq, V: Slice<T>> Equiv<V> for Vec<T> {
+impl<T: PartialEq, V: AsSlice<T>> Equiv<V> for Vec<T> {
     #[inline]
     fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
 }
@@ -1605,7 +1605,7 @@ impl<T: PartialEq> Vec<T> {
     }
 }
 
-impl<T> Slice<T> for Vec<T> {
+impl<T> AsSlice<T> for Vec<T> {
     /// Returns a slice into `self`.
     ///
     /// # Example
@@ -1623,7 +1623,7 @@ impl<T> Slice<T> for Vec<T> {
     }
 }
 
-impl<T: Clone, V: Slice<T>> Add<V, Vec<T>> for Vec<T> {
+impl<T: Clone, V: AsSlice<T>> Add<V, Vec<T>> for Vec<T> {
     #[inline]
     fn add(&self, rhs: &V) -> Vec<T> {
         let mut res = Vec::with_capacity(self.len() + rhs.as_slice().len());
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() }
 }
diff --git a/src/libgraphviz/maybe_owned_vec.rs b/src/libgraphviz/maybe_owned_vec.rs
index 94e89dc6043..50d957e1381 100644
--- a/src/libgraphviz/maybe_owned_vec.rs
+++ b/src/libgraphviz/maybe_owned_vec.rs
@@ -84,7 +84,7 @@ impl<'a, T: Ord> Ord for MaybeOwnedVector<'a, T> {
     }
 }
 
-impl<'a, T: PartialEq, V: Slice<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
+impl<'a, T: PartialEq, V: AsSlice<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
     fn equiv(&self, other: &V) -> bool {
         self.as_slice() == other.as_slice()
     }
@@ -99,7 +99,7 @@ impl<'a, T: PartialEq, V: Slice<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
 // In any case, with `Vector` in place, the client can just use
 // `as_slice` if they prefer that over `match`.
 
-impl<'b,T> Slice<T> for MaybeOwnedVector<'b,T> {
+impl<'b,T> AsSlice<T> for MaybeOwnedVector<'b,T> {
     fn as_slice<'a>(&'a self) -> &'a [T] {
         match self {
             &Growable(ref v) => v.as_slice(),
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs
index fe2b8a15c73..7a36680b3a6 100644
--- a/src/libstd/ascii.rs
+++ b/src/libstd/ascii.rs
@@ -19,7 +19,7 @@ use fmt;
 use iter::Iterator;
 use mem;
 use option::{Option, Some, None};
-use slice::{ImmutableSlice, MutableSlice, Slice};
+use slice::{ImmutableSlice, MutableSlice, AsSlice};
 use str::{Str, StrSlice};
 use string::{mod, String};
 use to_string::IntoStr;
diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs
index d8a7305810f..95f8ab72016 100644
--- a/src/libstd/c_vec.rs
+++ b/src/libstd/c_vec.rs
@@ -43,7 +43,7 @@ use option::{Option, Some, None};
 use ptr::RawPtr;
 use ptr;
 use raw;
-use slice::Slice;
+use slice::AsSlice;
 
 /// The type representing a foreign chunk of memory
 pub struct CVec<T> {
@@ -145,7 +145,7 @@ impl<T> CVec<T> {
     }
 }
 
-impl<T> Slice<T> for CVec<T> {
+impl<T> AsSlice<T> for CVec<T> {
     /// View the stored data as a slice.
     fn as_slice<'a>(&'a self) -> &'a [T] {
         unsafe {
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs
index bd2bd1ad090..5cd0b3010c5 100644
--- a/src/libstd/dynamic_lib.rs
+++ b/src/libstd/dynamic_lib.rs
@@ -29,7 +29,7 @@ use option::*;
 use os;
 use path::{Path,GenericPath};
 use result::*;
-use slice::{Slice,ImmutableSlice};
+use slice::{AsSlice,ImmutableSlice};
 use str;
 use string::String;
 use vec::Vec;
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs
index a93f9826fa5..57741db5ae2 100644
--- a/src/libstd/io/extensions.rs
+++ b/src/libstd/io/extensions.rs
@@ -23,7 +23,7 @@ use num::Int;
 use option::{Option, Some, None};
 use ptr::RawPtr;
 use result::{Ok, Err};
-use slice::{ImmutableSlice, Slice};
+use slice::{ImmutableSlice, AsSlice};
 
 /// An iterator that reads a single byte on each iteration,
 /// until `.read_byte()` returns `EndOfFile`.
diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs
index ca9692ee158..0f8e0ed52f8 100644
--- a/src/libstd/io/mem.rs
+++ b/src/libstd/io/mem.rs
@@ -19,7 +19,7 @@ use result::{Err, Ok};
 use io;
 use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
 use slice;
-use slice::Slice;
+use slice::AsSlice;
 use vec::Vec;
 
 static BUF_CAPACITY: uint = 128;
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index d279b88a1c5..280aff71e23 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -235,7 +235,7 @@ use os;
 use boxed::Box;
 use result::{Ok, Err, Result};
 use rt::rtio;
-use slice::{Slice, ImmutableSlice};
+use slice::{AsSlice, ImmutableSlice};
 use str::{Str, StrSlice};
 use str;
 use string::String;
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index c6948cccafe..bb642f1e48f 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -45,7 +45,7 @@ use path::{Path, GenericPath, BytesContainer};
 use ptr::RawPtr;
 use ptr;
 use result::{Err, Ok, Result};
-use slice::{Slice, ImmutableSlice, MutableSlice, ImmutablePartialEqSlice};
+use slice::{AsSlice, ImmutableSlice, MutableSlice, ImmutablePartialEqSlice};
 use slice::CloneableVector;
 use str::{Str, StrSlice, StrAllocating};
 use string::String;
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 63c81695aff..6a122990246 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -76,7 +76,7 @@ use option::{Option, None, Some};
 use str;
 use str::{MaybeOwned, Str, StrSlice};
 use string::String;
-use slice::{Slice, CloneableVector};
+use slice::{AsSlice, CloneableVector};
 use slice::{ImmutablePartialEqSlice, ImmutableSlice};
 use vec::Vec;
 
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 2425b40fef4..196ac7507ea 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -21,7 +21,7 @@ use iter::{DoubleEndedIterator, AdditiveIterator, Extendable, Iterator, Map};
 use option::{Option, None, Some};
 use str::Str;
 use str;
-use slice::{CloneableVector, Splits, Slice, VectorVector,
+use slice::{CloneableVector, Splits, AsSlice, VectorVector,
             ImmutablePartialEqSlice, ImmutableSlice};
 use vec::Vec;
 
@@ -367,7 +367,7 @@ impl Path {
 
     /// Returns a normalized byte vector representation of a path, by removing all empty
     /// components, and unnecessary . and .. components.
-    fn normalize<V: Slice<u8>+CloneableVector<u8>>(v: V) -> Vec<u8> {
+    fn normalize<V: AsSlice<u8>+CloneableVector<u8>>(v: V) -> Vec<u8> {
         // borrowck is being very picky
         let val = {
             let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == SEP_BYTE;
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 803db4848ad..ec3f87bc45a 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -23,7 +23,7 @@ use io::Writer;
 use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Iterator, Map};
 use mem;
 use option::{Option, Some, None};
-use slice::{Slice, ImmutableSlice};
+use slice::{AsSlice, ImmutableSlice};
 use str::{CharSplits, Str, StrAllocating, StrVector, StrSlice};
 use string::String;
 use unicode::char::UnicodeChar;
diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs
index 48ddfeaf5ff..a1e74c7254e 100644
--- a/src/libstd/prelude.rs
+++ b/src/libstd/prelude.rs
@@ -87,7 +87,7 @@
 #[doc(no_inline)] pub use slice::{MutableCloneableSlice, MutableOrdSlice};
 #[doc(no_inline)] pub use slice::{ImmutableSlice, MutableSlice};
 #[doc(no_inline)] pub use slice::{ImmutablePartialEqSlice, ImmutableOrdSlice};
-#[doc(no_inline)] pub use slice::{Slice, VectorVector};
+#[doc(no_inline)] pub use slice::{AsSlice, VectorVector};
 #[doc(no_inline)] pub use slice::MutableSliceAllocating;
 #[doc(no_inline)] pub use string::String;
 #[doc(no_inline)] pub use vec::Vec;
diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs
index d2c0ebd4393..3f5b524a9b5 100644
--- a/src/libsyntax/test.rs
+++ b/src/libsyntax/test.rs
@@ -414,7 +414,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<ast::ViewItem>) {
     let mainfn = (quote_item!(&mut cx.ext_cx,
         pub fn main() {
             #![main]
-            use std::slice::Slice;
+            use std::slice::AsSlice;
             test::test_main_static(::std::os::args().as_slice(), TESTS);
         }
     )).unwrap();