1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Utility macros for implementing PartialEq on slice-like types
16 macro_rules! __impl_slice_eq1 {
17 ($Lhs: ty, $Rhs: ty) => {
18 __impl_slice_eq1! { $Lhs, $Rhs, Sized }
20 ($Lhs: ty, $Rhs: ty, $Bound: ident) => {
21 #[stable(feature = "rust1", since = "1.0.0")]
22 impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> {
24 fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] }
26 fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] }
32 macro_rules! __impl_slice_eq2 {
33 ($Lhs: ty, $Rhs: ty) => {
34 __impl_slice_eq2! { $Lhs, $Rhs, Sized }
36 ($Lhs: ty, $Rhs: ty, $Bound: ident) => {
37 __impl_slice_eq1!($Lhs, $Rhs, $Bound);
39 #[stable(feature = "rust1", since = "1.0.0")]
40 impl<'a, 'b, A: $Bound, B> PartialEq<$Lhs> for $Rhs where B: PartialEq<A> {
42 fn eq(&self, other: &$Lhs) -> bool { self[..] == other[..] }
44 fn ne(&self, other: &$Lhs) -> bool { self[..] != other[..] }