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:
use vec::Vec;
pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows};
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};
pub use core::slice::{ImmutableOrdSlice, MutableSlice, Items, MutItems};
pub use core::slice::{MutSplits, MutChunks};
pub use core::slice::{bytes, MutableCloneableSlice};
fn connect_vec(&self, sep: &T) -> Vec<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);
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);
use core::fmt;
use core::mem;
use core::ptr;
use core::fmt;
use core::mem;
use core::ptr;
+// 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 {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.
use vec::Vec;
/// A growable string stored as a UTF-8 encoded buffer.
/// ```
pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> {
if str::is_utf8(v) {
/// ```
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;
}
static TAG_CONT_U8: u8 = 128u8;
unsafe {
// Attempt to not use an intermediate buffer by just pushing bytes
// directly onto this string.
unsafe {
// Attempt to not use an intermediate buffer by just pushing bytes
// directly onto this string.
data: self.vec.as_ptr().offset(cur_len as int),
len: 4,
};
data: self.vec.as_ptr().offset(cur_len as int),
len: 4,
};
use core::prelude::*;
use alloc::heap::{allocate, reallocate, deallocate};
use core::prelude::*;
use alloc::heap::{allocate, reallocate, deallocate};
+use RawSlice = core::raw::Slice;
+use core::slice::Slice;
use core::cmp::max;
use core::default::Default;
use core::fmt;
use core::cmp::max;
use core::default::Default;
use core::fmt;
impl<T: Eq> Eq for Vec<T> {}
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() }
}
#[inline]
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
}
#[inline]
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
unsafe {
#[inline]
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
unsafe {
+ mem::transmute(RawSlice {
data: self.as_mut_ptr() as *const T,
len: self.len,
})
data: self.as_mut_ptr() as *const T,
len: self.len,
})
-impl<T> Vector<T> for Vec<T> {
+impl<T> Slice<T> for Vec<T> {
/// Work with `self` as a slice.
///
/// # Example
/// Work with `self` as a slice.
///
/// # Example
/// ```
#[inline]
fn as_slice<'a>(&'a self) -> &'a [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());
#[inline]
fn add(&self, rhs: &V) -> Vec<T> {
let mut res = Vec::with_capacity(self.len() + rhs.as_slice().len());
use ops::Deref;
use result::{Ok, Err};
use result;
use ops::Deref;
use result::{Ok, Err};
use result;
-use slice::{Vector, ImmutableSlice};
+use slice::{Slice, ImmutableSlice};
use slice;
use str::StrSlice;
use str;
use slice;
use str::StrSlice;
use str;
use cmp::{PartialEq, Eq, Ord};
use default::Default;
use cmp::{PartialEq, Eq, Ord};
use default::Default;
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
use mem;
use slice;
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
use mem;
use slice;
// Trait implementations
/////////////////////////////////////////////////////////////////////////////
// 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] {
/// Convert from `Option<T>` to `&[T]` (without copying)
#[inline]
fn as_slice<'a>(&'a self) -> &'a [T] {
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
pub use slice::{ImmutableEqSlice, ImmutableOrdSlice};
pub use slice::{MutableSlice};
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};
use mem;
use mem::size_of;
use kinds::marker;
use mem;
use mem::size_of;
use kinds::marker;
+use raw::{Repr};
+// Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module.
+use RawSlice = raw::Slice;
assert!(start <= end);
assert!(end <= self.len());
unsafe {
assert!(start <= end);
assert!(end <= self.len());
unsafe {
data: self.as_ptr().offset(start as int),
len: (end - start)
})
data: self.as_ptr().offset(start as int),
len: (end - start)
})
fn shift_ref(&mut self) -> Option<&'a T> {
unsafe {
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
match raw::shift_ptr(s) {
Some(p) => Some(&*p),
None => None
fn pop_ref(&mut self) -> Option<&'a T> {
unsafe {
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
match raw::pop_ptr(s) {
Some(p) => Some(&*p),
None => None
assert!(start <= end);
assert!(end <= self.len());
unsafe {
assert!(start <= end);
assert!(end <= self.len());
unsafe {
data: self.as_mut_ptr().offset(start as int) as *const T,
len: (end - start)
})
data: self.as_mut_ptr().offset(start as int) as *const T,
len: (end - start)
})
fn mut_shift_ref(&mut self) -> Option<&'a mut T> {
unsafe {
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
match raw::shift_ptr(s) {
// FIXME #13933: this `&` -> `&mut` cast is a little
// dubious
fn mut_pop_ref(&mut self) -> Option<&'a mut T> {
unsafe {
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
match raw::pop_ptr(s) {
// FIXME #13933: this `&` -> `&mut` cast is a little
// dubious
//
/// Any vector that can be represented as a slice.
//
/// Any vector that can be represented as a slice.
/// Work with `self` as a slice.
fn as_slice<'a>(&'a self) -> &'a [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 }
}
#[inline(always)]
fn as_slice<'a>(&'a self) -> &'a [T] { *self }
}
*/
pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] {
unsafe {
*/
pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] {
unsafe {
- transmute(Slice { data: s, len: 1 })
+ transmute(RawSlice { data: s, len: 1 })
pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
unsafe {
let ptr: *const A = transmute(s);
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 })
impl<'a,T:Eq> Eq 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() }
}
#[inline]
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
}
-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()
}
fn equiv(&self, other: &V) -> bool {
self.as_slice() == other.as_slice()
}
// In any case, with `Vector` in place, the client can just use
// `as_slice` if they prefer that over `match`.
// 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(),
fn as_slice<'a>(&'a self) -> &'a [T] {
match self {
&Growable(ref v) => v.as_slice(),
let mainfn = (quote_item!(&cx.ext_cx,
pub fn main() {
#![main]
let mainfn = (quote_item!(&cx.ext_cx,
pub fn main() {
#![main]
- use std::slice::Vector;
test::test_main_static(::std::os::args().as_slice(), TESTS);
}
)).unwrap();
test::test_main_static(::std::os::args().as_slice(), TESTS);
}
)).unwrap();
use iter::Iterator;
use mem;
use option::{Option, Some, None};
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;
use str::{Str, StrSlice};
use str;
use string::String;
use ptr::RawPtr;
use ptr;
use raw;
use ptr::RawPtr;
use ptr;
use raw;
/// The type representing a foreign chunk of memory
pub struct CVec<T> {
/// The type representing a foreign chunk of memory
pub struct CVec<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 {
/// View the stored data as a slice.
fn as_slice<'a>(&'a self) -> &'a [T] {
unsafe {
use os;
use path::{Path,GenericPath};
use result::*;
use os;
use path::{Path,GenericPath};
use result::*;
-use slice::{Vector,ImmutableSlice};
+use slice::{Slice,ImmutableSlice};
use str;
use string::String;
use vec::Vec;
use str;
use string::String;
use vec::Vec;
use result::{Ok, Err};
use io;
use io::{IoError, IoResult, Reader};
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,
use ptr::RawPtr;
/// An iterator that reads a single byte on each iteration,
use io;
use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
use slice;
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;
use vec::Vec;
static BUF_CAPACITY: uint = 128;
use boxed::Box;
use result::{Ok, Err, Result};
use rt::rtio;
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;
use str::{Str, StrSlice};
use str;
use string::String;
use ptr::RawPtr;
use ptr;
use result::{Err, Ok, Result};
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};
use str::{Str, StrSlice, StrAllocating};
use string::String;
use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
use str;
use str::{MaybeOwned, Str, StrSlice};
use string::String;
use str;
use str::{MaybeOwned, Str, StrSlice};
use string::String;
use slice::{ImmutableEqSlice, ImmutableSlice};
use vec::Vec;
use slice::{ImmutableEqSlice, ImmutableSlice};
use vec::Vec;
use option::{Option, None, Some};
use str::Str;
use str;
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;
ImmutableEqSlice, ImmutableSlice};
use vec::Vec;
/// Returns a normalized byte vector representation of a path, by removing all empty
/// components, and unnecessary . and .. components.
/// 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;
// borrowck is being very picky
let val = {
let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == SEP_BYTE;
use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Iterator, Map};
use mem;
use option::{Option, Some, None};
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;
use str::{CharSplits, Str, StrAllocating, StrVector, StrSlice};
use string::String;
use unicode::char::UnicodeChar;
#[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::{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;
#[doc(no_inline)] pub use slice::MutableSliceAllocating;
#[doc(no_inline)] pub use string::String;
#[doc(no_inline)] pub use vec::Vec;