std,extra: remove use of & support for @[].

This commit is contained in:
Huon Wilson 2014-02-01 15:57:17 +11:00
parent e0c1707560
commit 2ed980fe25
14 changed files with 2 additions and 566 deletions

View file

@ -646,13 +646,6 @@ pub mod traits {
fn ne(&self, other: &~[T]) -> bool { !self.eq(other) }
}
impl<T:Eq> Eq for @[T] {
#[inline]
fn eq(&self, other: &@[T]) -> bool { self.as_slice() == *other }
#[inline]
fn ne(&self, other: &@[T]) -> bool { !self.eq(other) }
}
impl<'a,T:TotalEq> TotalEq for &'a [T] {
fn equals(&self, other: & &'a [T]) -> bool {
self.len() == other.len() &&
@ -665,11 +658,6 @@ pub mod traits {
fn equals(&self, other: &~[T]) -> bool { self.as_slice().equals(&other.as_slice()) }
}
impl<T:TotalEq> TotalEq for @[T] {
#[inline]
fn equals(&self, other: &@[T]) -> bool { self.as_slice().equals(&other.as_slice()) }
}
impl<'a,T:Eq, V: Vector<T>> Equiv<V> for &'a [T] {
#[inline]
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
@ -680,11 +668,6 @@ pub mod traits {
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
}
impl<'a,T:Eq, V: Vector<T>> Equiv<V> for @[T] {
#[inline]
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
}
impl<'a,T:TotalOrd> TotalOrd for &'a [T] {
fn cmp(&self, other: & &'a [T]) -> Ordering {
order::cmp(self.iter(), other.iter())
@ -696,11 +679,6 @@ pub mod traits {
fn cmp(&self, other: &~[T]) -> Ordering { self.as_slice().cmp(&other.as_slice()) }
}
impl<T: TotalOrd> TotalOrd for @[T] {
#[inline]
fn cmp(&self, other: &@[T]) -> Ordering { self.as_slice().cmp(&other.as_slice()) }
}
impl<'a, T: Eq + Ord> Ord for &'a [T] {
fn lt(&self, other: & &'a [T]) -> bool {
order::lt(self.iter(), other.iter())
@ -730,17 +708,6 @@ pub mod traits {
fn gt(&self, other: &~[T]) -> bool { self.as_slice() > other.as_slice() }
}
impl<T: Eq + Ord> Ord for @[T] {
#[inline]
fn lt(&self, other: &@[T]) -> bool { self.as_slice() < other.as_slice() }
#[inline]
fn le(&self, other: &@[T]) -> bool { self.as_slice() <= other.as_slice() }
#[inline]
fn ge(&self, other: &@[T]) -> bool { self.as_slice() >= other.as_slice() }
#[inline]
fn gt(&self, other: &@[T]) -> bool { self.as_slice() > other.as_slice() }
}
impl<'a,T:Clone, V: Vector<T>> Add<V, ~[T]> for &'a [T] {
#[inline]
fn add(&self, rhs: &V) -> ~[T] {
@ -778,11 +745,6 @@ impl<T> Vector<T> for ~[T] {
fn as_slice<'a>(&'a self) -> &'a [T] { let v: &'a [T] = *self; v }
}
impl<T> Vector<T> for @[T] {
#[inline(always)]
fn as_slice<'a>(&'a self) -> &'a [T] { let v: &'a [T] = *self; v }
}
impl<'a, T> Container for &'a [T] {
/// Returns the length of a vector
#[inline]
@ -833,15 +795,6 @@ impl<T: Clone> CloneableVector<T> for ~[T] {
fn into_owned(self) -> ~[T] { self }
}
/// Extension methods for managed vectors
impl<T: Clone> CloneableVector<T> for @[T] {
#[inline]
fn to_owned(&self) -> ~[T] { self.as_slice().to_owned() }
#[inline(always)]
fn into_owned(self) -> ~[T] { self.to_owned() }
}
/// Extension methods for vectors
pub trait ImmutableVector<'a, T> {
/**
@ -2629,10 +2582,6 @@ impl<A> Default for ~[A] {
fn default() -> ~[A] { ~[] }
}
impl<A> Default for @[A] {
fn default() -> @[A] { @[] }
}
macro_rules! iterator {
(struct $name:ident -> $ptr:ty, $elem:ty) => {
/// An iterator for iterating over a vector.
@ -3109,14 +3058,6 @@ mod tests {
assert_eq!(v_b[0], 2);
assert_eq!(v_b[1], 3);
// Test on managed heap.
let vec_managed = @[1, 2, 3, 4, 5];
let v_c = vec_managed.slice(0u, 3u).to_owned();
assert_eq!(v_c.len(), 3u);
assert_eq!(v_c[0], 1);
assert_eq!(v_c[1], 2);
assert_eq!(v_c[2], 3);
// Test on exchange heap.
let vec_unique = ~[1, 2, 3, 4, 5, 6];
let v_d = vec_unique.slice(1u, 6u).to_owned();
@ -4052,7 +3993,6 @@ mod tests {
);
t!(&[int]);
t!(@[int]);
t!(~[int]);
}