1use super::Vec;
2use crate::alloc::Allocator;
3#[cfg(not(no_global_oom_handling))]
4use crate::borrow::Cow;
5
6macro_rules! __impl_slice_eq1 {
7 ([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, #[$stability:meta]) => {
8 #[$stability]
9 impl<T, U, $($vars)*> PartialEq<$rhs> for $lhs
10 where
11 T: PartialEq<U>,
12 $($ty: $bound)?
13 {
14 #[inline]
15 fn eq(&self, other: &$rhs) -> bool { self[..] == other[..] }
16 #[inline]
17 fn ne(&self, other: &$rhs) -> bool { self[..] != other[..] }
18 }
19 }
20}
21
22#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U, A1: Allocator, A2: Allocator> PartialEq<Vec<U, A2>> for Vec<T, A1>
where T: PartialEq<U> {
#[inline]
fn eq(&self, other: &Vec<U, A2>) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &Vec<U, A2>) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A1: Allocator, A2: Allocator] Vec<T, A1>, Vec<U, A2>, #[stable(feature = "rust1", since = "1.0.0")] }
23#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U, A: Allocator> PartialEq<&[U]> for Vec<T, A> where T: PartialEq<U> {
#[inline]
fn eq(&self, other: &&[U]) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &&[U]) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator] Vec<T, A>, &[U], #[stable(feature = "rust1", since = "1.0.0")] }
24#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U, A: Allocator> PartialEq<&mut [U]> for Vec<T, A> where
T: PartialEq<U> {
#[inline]
fn eq(&self, other: &&mut [U]) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &&mut [U]) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator] Vec<T, A>, &mut [U], #[stable(feature = "rust1", since = "1.0.0")] }
25#[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")]
impl<T, U, A: Allocator> PartialEq<Vec<U, A>> for &[T] where T: PartialEq<U> {
#[inline]
fn eq(&self, other: &Vec<U, A>) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &Vec<U, A>) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator] &[T], Vec<U, A>, #[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")] }
26#[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")]
impl<T, U, A: Allocator> PartialEq<Vec<U, A>> for &mut [T] where
T: PartialEq<U> {
#[inline]
fn eq(&self, other: &Vec<U, A>) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &Vec<U, A>) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator] &mut [T], Vec<U, A>, #[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")] }
27#[stable(feature = "partialeq_vec_for_slice", since = "1.48.0")]
impl<T, U, A: Allocator> PartialEq<[U]> for Vec<T, A> where T: PartialEq<U> {
#[inline]
fn eq(&self, other: &[U]) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &[U]) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator] Vec<T, A>, [U], #[stable(feature = "partialeq_vec_for_slice", since = "1.48.0")] }
28#[stable(feature = "partialeq_vec_for_slice", since = "1.48.0")]
impl<T, U, A: Allocator> PartialEq<Vec<U, A>> for [T] where T: PartialEq<U> {
#[inline]
fn eq(&self, other: &Vec<U, A>) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &Vec<U, A>) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator] [T], Vec<U, A>, #[stable(feature = "partialeq_vec_for_slice", since = "1.48.0")] }
29#[cfg(not(no_global_oom_handling))]
30#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U, A: Allocator> PartialEq<Vec<U, A>> for Cow<'_, [T]> where
T: PartialEq<U>, T: Clone {
#[inline]
fn eq(&self, other: &Vec<U, A>) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &Vec<U, A>) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator] Cow<'_, [T]>, Vec<U, A> where T: Clone, #[stable(feature = "rust1", since = "1.0.0")] }
31#[cfg(not(no_global_oom_handling))]
32#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U> PartialEq<&[U]> for Cow<'_, [T]> where T: PartialEq<U>, T: Clone {
#[inline]
fn eq(&self, other: &&[U]) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &&[U]) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [] Cow<'_, [T]>, &[U] where T: Clone, #[stable(feature = "rust1", since = "1.0.0")] }
33#[cfg(not(no_global_oom_handling))]
34#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U> PartialEq<&mut [U]> for Cow<'_, [T]> where T: PartialEq<U>,
T: Clone {
#[inline]
fn eq(&self, other: &&mut [U]) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &&mut [U]) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [] Cow<'_, [T]>, &mut [U] where T: Clone, #[stable(feature = "rust1", since = "1.0.0")] }
35#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U, A: Allocator, const N : usize> PartialEq<[U; N]> for Vec<T, A>
where T: PartialEq<U> {
#[inline]
fn eq(&self, other: &[U; N]) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &[U; N]) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator, const N: usize] Vec<T, A>, [U; N], #[stable(feature = "rust1", since = "1.0.0")] }
36#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U, A: Allocator, const N : usize> PartialEq<&[U; N]> for Vec<T, A>
where T: PartialEq<U> {
#[inline]
fn eq(&self, other: &&[U; N]) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &&[U; N]) -> bool { self[..] != other[..] }
}__impl_slice_eq1! { [A: Allocator, const N: usize] Vec<T, A>, &[U; N], #[stable(feature = "rust1", since = "1.0.0")] }
37
38