Rename slice::Slice
This commit is contained in:
parent
2d3823441f
commit
cd21e4a72c
22 changed files with 30 additions and 68 deletions
|
@ -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};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
@ -840,26 +839,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
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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() }
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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`.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue