diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-08-06 11:59:40 +0200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-08-26 16:07:32 +1200 |
| commit | 52ef46251ede1ff51e5d5621d5fe2614e950f963 (patch) | |
| tree | 481371289f467bc89a6d6dc769635dac1d47a6cb /src/libcore | |
| parent | 3e626375d8d2226a203bf6ea6e98dab14774c59f (diff) | |
Rebasing changes
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cmp.rs | 5 | ||||
| -rw-r--r-- | src/libcore/option.rs | 5 | ||||
| -rw-r--r-- | src/libcore/raw.rs | 4 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 21 |
4 files changed, 30 insertions, 5 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index bfd10c835e2..b90c6daf9eb 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -112,12 +112,13 @@ impl Ordering { /// assert_eq!(Greater.reverse(), Less); /// /// - /// let mut data = &mut [2u, 10, 5, 8]; + /// let mut data: &mut [_] = &mut [2u, 10, 5, 8]; /// /// // sort the array from largest to smallest. /// data.sort_by(|a, b| a.cmp(b).reverse()); /// - /// assert_eq!(data, &mut [10u, 8, 5, 2]); + /// let b: &mut [_] = &mut [10u, 8, 5, 2]; + /// assert!(data == b); /// ``` #[inline] #[experimental] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 47df8ae68cd..7773e03416e 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -530,7 +530,10 @@ impl<T> Slice<T> for Option<T> { fn as_slice<'a>(&'a self) -> &'a [T] { match *self { Some(ref x) => slice::ref_slice(x), - None => &[] + None => { + let result: &[_] = &[]; + result + } } } } diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index aa8a4976867..5daa693c774 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -58,8 +58,8 @@ pub struct TraitObject { } #[cfg(not(stage0))] pub struct TraitObject { - pub data: *(), - pub vtable: *(), + pub data: *mut (), + pub vtable: *mut (), } /// This trait is meant to map equivalences between raw structs and their diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 8c55662f163..475c2e94ec7 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1649,6 +1649,27 @@ impl<'a,T:PartialEq, V: Slice<T>> Equiv<V> for &'a [T] { } #[unstable = "waiting for DST"] +impl<'a,T:PartialEq> PartialEq for &'a mut [T] { + fn eq(&self, other: & &'a mut [T]) -> bool { + self.len() == other.len() && + order::eq(self.iter(), other.iter()) + } + fn ne(&self, other: & &'a mut [T]) -> bool { + self.len() != other.len() || + order::ne(self.iter(), other.iter()) + } +} + +#[unstable = "waiting for DST"] +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] { + #[inline] + fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } +} + +#[unstable = "waiting for DST"] impl<'a,T:Ord> Ord for &'a [T] { fn cmp(&self, other: & &'a [T]) -> Ordering { order::cmp(self.iter(), other.iter()) |
