Update for new blanket impl rules.

This commit is contained in:
Victor Berger
2015-04-03 22:46:10 +02:00
parent fb67281e72
commit 635274752b
2 changed files with 38 additions and 29 deletions
+13 -4
View File
@@ -254,8 +254,10 @@ pub trait ByteStr : Clone + Sized + Send + Sync + Reflect + ToBytes + ops::Index
} }
} }
impl<B1: ByteStr, B2: ByteStr> cmp::PartialEq<B2> for B1 { macro_rules! impl_parteq {
fn eq(&self, other: &B2) -> bool { ($ty:ty) => {
impl<B: ByteStr> cmp::PartialEq<B> for $ty {
fn eq(&self, other: &B) -> bool {
if self.len() != other.len() { if self.len() != other.len() {
return false; return false;
} }
@@ -284,11 +286,18 @@ impl<B1: ByteStr, B2: ByteStr> cmp::PartialEq<B2> for B1 {
true true
} }
fn ne(&self, other: &B2) -> bool { fn ne(&self, other: &B) -> bool {
return !self.eq(other) return !self.eq(other)
} }
}
}
} }
impl_parteq!(SeqByteStr);
impl_parteq!(SmallByteStr);
impl_parteq!(Bytes);
impl_parteq!(Rope);
macro_rules! impl_eq { macro_rules! impl_eq {
($ty:ty) => { ($ty:ty) => {
impl cmp::Eq for $ty {} impl cmp::Eq for $ty {}
@@ -549,7 +558,7 @@ impl_write!(MutByteBuf);
* *
*/ */
#[derive(Copy, Debug)] #[derive(Copy, Clone, Debug)]
pub enum BufError { pub enum BufError {
Underflow, Underflow,
Overflow, Overflow,
+1 -1
View File
@@ -36,7 +36,7 @@ pub fn test_rope_round_trip() {
let mut dst = vec![]; let mut dst = vec![];
rope.buf().read(&mut dst).unwrap(); rope.buf().read(&mut dst).unwrap();
assert_eq!(b"zomg", dst); assert_eq!(b"zomg", &dst[..]);
} }
#[test] #[test]