]> git.lizzy.rs Git - rust.git/commitdiff
std: Rename slice::Vector to Slice
authorBrian Anderson <banderson@mozilla.com>
Thu, 7 Aug 2014 03:03:55 +0000 (20:03 -0700)
committerBrian Anderson <banderson@mozilla.com>
Wed, 13 Aug 2014 18:30:14 +0000 (11:30 -0700)
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]

20 files changed:
src/libcollections/slice.rs
src/libcollections/string.rs
src/libcollections/vec.rs
src/libcore/fmt/mod.rs
src/libcore/option.rs
src/libcore/prelude.rs
src/libcore/slice.rs
src/libgraphviz/maybe_owned_vec.rs
src/librustc/front/test.rs
src/libstd/ascii.rs
src/libstd/c_vec.rs
src/libstd/dynamic_lib.rs
src/libstd/io/extensions.rs
src/libstd/io/mem.rs
src/libstd/io/mod.rs
src/libstd/os.rs
src/libstd/path/mod.rs
src/libstd/path/posix.rs
src/libstd/path/windows.rs
src/libstd/prelude.rs

index d73fa49984898989f2d2a2c3974ba6da133e497b..9f4bdaf3da3d95d2e6f3fecfbb9315329d93cac4 100644 (file)
@@ -98,7 +98,7 @@
 use vec::Vec;
 
 pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows};
-pub use core::slice::{Chunks, Vector, ImmutableSlice, ImmutableEqSlice};
+pub use core::slice::{Chunks, Slice, ImmutableSlice, ImmutableEqSlice};
 pub use core::slice::{ImmutableOrdSlice, MutableSlice, Items, MutItems};
 pub use core::slice::{MutSplits, MutChunks};
 pub use core::slice::{bytes, MutableCloneableSlice};
@@ -116,7 +116,7 @@ pub trait VectorVector<T> {
     fn connect_vec(&self, sep: &T) -> Vec<T>;
 }
 
-impl<'a, T: Clone, V: Vector<T>> VectorVector<T> for &'a [V] {
+impl<'a, T: Clone, V: Slice<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);
index 952f28da2af891980a6bafc96d723979fdb39b1f..d8cc80fdf41d76e9e3982ddf09b09efe5761af78 100644 (file)
 use core::fmt;
 use core::mem;
 use core::ptr;
-use core::raw::Slice;
+// FIXME: ICE's abound if you import the `Slice` type while importing `Slice` trait
+use RawSlice = core::raw::Slice;
+use core::slice::Slice;
 
 use {Collection, Mutable, MutableSeq};
 use hash;
 use str;
-use str::{CharRange, StrAllocating, MaybeOwned, Owned, Slice};
+use str::{CharRange, StrAllocating, MaybeOwned, Owned};
+use MaybeOwnedSlice = str::Slice; // So many `Slice`s...
 use vec::Vec;
 
 /// A growable string stored as a UTF-8 encoded buffer.
@@ -130,7 +133,7 @@ pub fn from_utf8(vec: Vec<u8>) -> Result<String, Vec<u8>> {
     /// ```
     pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> {
         if str::is_utf8(v) {
-            return Slice(unsafe { mem::transmute(v) })
+            return MaybeOwnedSlice(unsafe { mem::transmute(v) })
         }
 
         static TAG_CONT_U8: u8 = 128u8;
@@ -496,7 +499,7 @@ pub fn push_char(&mut self, ch: char) {
         unsafe {
             // Attempt to not use an intermediate buffer by just pushing bytes
             // directly onto this string.
-            let slice = Slice {
+            let slice = RawSlice {
                 data: self.vec.as_ptr().offset(cur_len as int),
                 len: 4,
             };
index 4c1530d1bfbe9120ce4373d293de568689298245..78809e32fe9cb438d4b807c0104fd0e7b5a760fb 100644 (file)
@@ -13,7 +13,8 @@
 use core::prelude::*;
 
 use alloc::heap::{allocate, reallocate, deallocate};
-use core::raw::Slice;
+use RawSlice = core::raw::Slice;
+use core::slice::Slice;
 use core::cmp::max;
 use core::default::Default;
 use core::fmt;
@@ -506,7 +507,7 @@ fn partial_cmp(&self, other: &Vec<T>) -> Option<Ordering> {
 
 impl<T: Eq> Eq for Vec<T> {}
 
-impl<T: PartialEq, V: Vector<T>> Equiv<V> for Vec<T> {
+impl<T: PartialEq, V: Slice<T>> Equiv<V> for Vec<T> {
     #[inline]
     fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
 }
@@ -720,7 +721,7 @@ pub fn truncate(&mut self, len: uint) {
     #[inline]
     pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
         unsafe {
-            mem::transmute(Slice {
+            mem::transmute(RawSlice {
                 data: self.as_mut_ptr() as *const T,
                 len: self.len,
             })
@@ -1502,7 +1503,7 @@ pub fn dedup(&mut self) {
     }
 }
 
-impl<T> Vector<T> for Vec<T> {
+impl<T> Slice<T> for Vec<T> {
     /// Work with `self` as a slice.
     ///
     /// # Example
@@ -1515,11 +1516,11 @@ impl<T> Vector<T> for Vec<T> {
     /// ```
     #[inline]
     fn as_slice<'a>(&'a self) -> &'a [T] {
-        unsafe { mem::transmute(Slice { data: self.as_ptr(), len: self.len }) }
+        unsafe { mem::transmute(RawSlice { data: self.as_ptr(), len: self.len }) }
     }
 }
 
-impl<T: Clone, V: Vector<T>> Add<V, Vec<T>> for Vec<T> {
+impl<T: Clone, V: Slice<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());
index 61f0d09453f2b1b44f0d177b13aa944cdf891093..942f7f8b71019f2db0ecdf495b620f86a92caf9b 100644 (file)
@@ -24,7 +24,7 @@
 use ops::Deref;
 use result::{Ok, Err};
 use result;
-use slice::{Vector, ImmutableSlice};
+use slice::{Slice, ImmutableSlice};
 use slice;
 use str::StrSlice;
 use str;
index f8293aeb03d1910651677ceb44175a797730e9ab..74d87712a02ef96cc6d36a44a0f6f3558077fa87 100644 (file)
 
 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 @@ pub fn unwrap_or_default(self) -> 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] {
index 08a431b0d1f233bed5543d8fbf484dead1387ced..2d5c9c0e960833ee394e73bb747ee0bd15ff486d 100644 (file)
@@ -63,4 +63,4 @@
 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};
index 6c8bacaef48e2f4e73b0d390cecced7d76fb9f63..3a619b45e53a1611169abbca5554ab9f1498bbaa 100644 (file)
@@ -47,7 +47,9 @@
 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 @@ fn slice(&self, start: uint, end: uint) -> &'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 @@ fn bsearch(&self, f: |&T| -> Ordering) -> Option<uint> {
 
     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 @@ fn shift_ref(&mut self) -> Option<&'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 @@ fn mut_slice(self, start: uint, end: uint) -> &'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 @@ fn mut_chunks(self, chunk_size: uint) -> MutChunks<'a, 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 @@ fn mut_shift_ref(&mut self) -> Option<&'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 @@ fn copy_from(self, src: &[T]) -> uint {
 //
 
 /// 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 @@ fn next_back(&mut self) -> Option<&'a mut [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 @@ fn ne(&self, other: & &'a [T]) -> bool {
 
 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() }
 }
index 9e52af72138bba2fb839a25a8554b733956677d6..987f214b153e07d3ba107024563594cf6b27ee2c 100644 (file)
@@ -84,7 +84,7 @@ fn cmp(&self, other: &MaybeOwnedVector<T>) -> Ordering {
     }
 }
 
-impl<'a, T: PartialEq, V: Vector<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
+impl<'a, T: PartialEq, V: Slice<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
     fn equiv(&self, other: &V) -> bool {
         self.as_slice() == other.as_slice()
     }
@@ -99,7 +99,7 @@ fn equiv(&self, other: &V) -> bool {
 // In any case, with `Vector` in place, the client can just use
 // `as_slice` if they prefer that over `match`.
 
-impl<'b,T> slice::Vector<T> for MaybeOwnedVector<'b,T> {
+impl<'b,T> Slice<T> for MaybeOwnedVector<'b,T> {
     fn as_slice<'a>(&'a self) -> &'a [T] {
         match self {
             &Growable(ref v) => v.as_slice(),
index 14cda7d62c35def4dc62053e12af7a95184c1f61..ceb7dcc54560c04931744bf91f3dbaeecdcd0d1d 100644 (file)
@@ -379,7 +379,7 @@ fn mk_test_module(cx: &TestCtxt, reexport_test_harness_main: &Option<InternedStr
     let mainfn = (quote_item!(&cx.ext_cx,
         pub fn main() {
             #![main]
-            use std::slice::Vector;
+            use std::slice::Slice;
             test::test_main_static(::std::os::args().as_slice(), TESTS);
         }
     )).unwrap();
index 6e442a018a068997c48ba37af49ee502e994a0be..e5f42bd65a30071d21dae7840c6f761cebb8edfe 100644 (file)
@@ -19,7 +19,7 @@
 use iter::Iterator;
 use mem;
 use option::{Option, Some, None};
-use slice::{ImmutableSlice, MutableSlice, Vector};
+use slice::{ImmutableSlice, MutableSlice, Slice};
 use str::{Str, StrSlice};
 use str;
 use string::String;
index 80fe05fcea5cdf99f1cdc14179c4af21dfd3324d..5f52c0ada5d62d2d4077ab21864a905d839a885d 100644 (file)
@@ -43,7 +43,7 @@
 use ptr::RawPtr;
 use ptr;
 use raw;
-use slice::Vector;
+use slice::Slice;
 
 /// The type representing a foreign chunk of memory
 pub struct CVec<T> {
@@ -145,7 +145,7 @@ pub unsafe fn unwrap(mut self) -> *mut T {
     }
 }
 
-impl<T> Vector<T> for CVec<T> {
+impl<T> Slice<T> for CVec<T> {
     /// View the stored data as a slice.
     fn as_slice<'a>(&'a self) -> &'a [T] {
         unsafe {
index f3bdd987122cdb62922e5c305c9989477e74eea6..766f92292b1875d5b163bdfa4ef1b89143f61f1a 100644 (file)
@@ -29,7 +29,7 @@
 use os;
 use path::{Path,GenericPath};
 use result::*;
-use slice::{Vector,ImmutableSlice};
+use slice::{Slice,ImmutableSlice};
 use str;
 use string::String;
 use vec::Vec;
index c40ea749376a07faf087e8a7319e3ca2ffa322bd..12caa7158658e28693df873b74ab099b4e6505c0 100644 (file)
@@ -21,7 +21,7 @@
 use result::{Ok, Err};
 use io;
 use io::{IoError, IoResult, Reader};
-use slice::{ImmutableSlice, Vector};
+use slice::{ImmutableSlice, Slice};
 use ptr::RawPtr;
 
 /// An iterator that reads a single byte on each iteration,
index e6866f45948565a23db43eeba6ec9eb4a2b68c7c..ea9d08171e6cef2794753ab83d141915cd2d0b93 100644 (file)
@@ -19,7 +19,7 @@
 use io;
 use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
 use slice;
-use slice::{Vector, ImmutableSlice, MutableSlice};
+use slice::{Slice, ImmutableSlice, MutableSlice};
 use vec::Vec;
 
 static BUF_CAPACITY: uint = 128;
index fa21c108ea342e71170ce951e3cdcbcb1b47ab12..c95dd8618ed10a7648e14f8f07939117a3a3d9ad 100644 (file)
@@ -235,7 +235,7 @@ fn file_product(p: &Path) -> IoResult<u32> {
 use boxed::Box;
 use result::{Ok, Err, Result};
 use rt::rtio;
-use slice::{Vector, MutableSlice, ImmutableSlice};
+use slice::{Slice, MutableSlice, ImmutableSlice};
 use str::{Str, StrSlice};
 use str;
 use string::String;
index 0d604aab8acbe044109de1eedebfaefa53aa026c..6f148eea83c833b9e488b29d4fc5e135ac1d10f1 100644 (file)
@@ -45,7 +45,7 @@
 use ptr::RawPtr;
 use ptr;
 use result::{Err, Ok, Result};
-use slice::{Vector, ImmutableSlice, MutableSlice, ImmutableEqSlice};
+use slice::{Slice, ImmutableSlice, MutableSlice, ImmutableEqSlice};
 use str::{Str, StrSlice, StrAllocating};
 use string::String;
 use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
index 087b3e4c53f4f6860b716ef52758639d6e8f4444..16236c014724da9309fe6d9d9229d8c79502e734 100644 (file)
@@ -74,7 +74,7 @@
 use str;
 use str::{MaybeOwned, Str, StrSlice};
 use string::String;
-use slice::Vector;
+use slice::Slice;
 use slice::{ImmutableEqSlice, ImmutableSlice};
 use vec::Vec;
 
index 81abf3e7669b605752aa7326e06de35eb461a065..321ec438c2024db4ecc7bea6783472cf9c725d08 100644 (file)
@@ -21,7 +21,7 @@
 use option::{Option, None, Some};
 use str::Str;
 use str;
-use slice::{CloneableVector, Splits, Vector, VectorVector,
+use slice::{CloneableVector, Splits, Slice, VectorVector,
             ImmutableEqSlice, ImmutableSlice};
 use vec::Vec;
 
@@ -367,7 +367,7 @@ pub fn new_opt<T: BytesContainer>(path: T) -> Option<Path> {
 
     /// Returns a normalized byte vector representation of a path, by removing all empty
     /// components, and unnecessary . and .. components.
-    fn normalize<V: Vector<u8>+CloneableVector<u8>>(v: V) -> Vec<u8> {
+    fn normalize<V: Slice<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;
index ca8eae769bba87c3235ea6a4946ed9beaa4ae481..8402d751bf2c81f54d1e5cfee784325ee1dd4cc8 100644 (file)
@@ -23,7 +23,7 @@
 use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Iterator, Map};
 use mem;
 use option::{Option, Some, None};
-use slice::{Vector, ImmutableSlice};
+use slice::{Slice, ImmutableSlice};
 use str::{CharSplits, Str, StrAllocating, StrVector, StrSlice};
 use string::String;
 use unicode::char::UnicodeChar;
index d5d24d17d865da30870981c22c5c9a83af73dd4b..3d4ab66a94f31ff423f2c63884cd6c95cdaa192a 100644 (file)
@@ -86,7 +86,7 @@
 #[doc(no_inline)] pub use slice::{MutableCloneableSlice, MutableOrdSlice};
 #[doc(no_inline)] pub use slice::{ImmutableSlice, MutableSlice};
 #[doc(no_inline)] pub use slice::{ImmutableEqSlice, ImmutableOrdSlice};
-#[doc(no_inline)] pub use slice::{Vector, VectorVector};
+#[doc(no_inline)] pub use slice::{Slice, VectorVector};
 #[doc(no_inline)] pub use slice::MutableSliceAllocating;
 #[doc(no_inline)] pub use string::String;
 #[doc(no_inline)] pub use vec::Vec;