1*057b8d25SMiguel Ojeda // SPDX-License-Identifier: Apache-2.0 OR MIT 2*057b8d25SMiguel Ojeda 3753dece8SMiguel Ojeda use crate::alloc::Allocator; 4753dece8SMiguel Ojeda #[cfg(not(no_global_oom_handling))] 5753dece8SMiguel Ojeda use crate::borrow::Cow; 6753dece8SMiguel Ojeda 7753dece8SMiguel Ojeda use super::Vec; 8753dece8SMiguel Ojeda 9753dece8SMiguel Ojeda macro_rules! __impl_slice_eq1 { 10753dece8SMiguel Ojeda ([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, #[$stability:meta]) => { 11753dece8SMiguel Ojeda #[$stability] 12753dece8SMiguel Ojeda impl<T, U, $($vars)*> PartialEq<$rhs> for $lhs 13753dece8SMiguel Ojeda where 14753dece8SMiguel Ojeda T: PartialEq<U>, 15753dece8SMiguel Ojeda $($ty: $bound)? 16753dece8SMiguel Ojeda { 17753dece8SMiguel Ojeda #[inline] 18753dece8SMiguel Ojeda fn eq(&self, other: &$rhs) -> bool { self[..] == other[..] } 19753dece8SMiguel Ojeda #[inline] 20753dece8SMiguel Ojeda fn ne(&self, other: &$rhs) -> bool { self[..] != other[..] } 21753dece8SMiguel Ojeda } 22753dece8SMiguel Ojeda } 23753dece8SMiguel Ojeda } 24753dece8SMiguel Ojeda 25753dece8SMiguel Ojeda __impl_slice_eq1! { [A1: Allocator, A2: Allocator] Vec<T, A1>, Vec<U, A2>, #[stable(feature = "rust1", since = "1.0.0")] } 26753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator] Vec<T, A>, &[U], #[stable(feature = "rust1", since = "1.0.0")] } 27753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator] Vec<T, A>, &mut [U], #[stable(feature = "rust1", since = "1.0.0")] } 28753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator] &[T], Vec<U, A>, #[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")] } 29753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator] &mut [T], Vec<U, A>, #[stable(feature = "partialeq_vec_for_ref_slice", since = "1.46.0")] } 30753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator] Vec<T, A>, [U], #[stable(feature = "partialeq_vec_for_slice", since = "1.48.0")] } 31753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator] [T], Vec<U, A>, #[stable(feature = "partialeq_vec_for_slice", since = "1.48.0")] } 32753dece8SMiguel Ojeda #[cfg(not(no_global_oom_handling))] 33753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator] Cow<'_, [T]>, Vec<U, A> where T: Clone, #[stable(feature = "rust1", since = "1.0.0")] } 34753dece8SMiguel Ojeda #[cfg(not(no_global_oom_handling))] 35753dece8SMiguel Ojeda __impl_slice_eq1! { [] Cow<'_, [T]>, &[U] where T: Clone, #[stable(feature = "rust1", since = "1.0.0")] } 36753dece8SMiguel Ojeda #[cfg(not(no_global_oom_handling))] 37753dece8SMiguel Ojeda __impl_slice_eq1! { [] Cow<'_, [T]>, &mut [U] where T: Clone, #[stable(feature = "rust1", since = "1.0.0")] } 38753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator, const N: usize] Vec<T, A>, [U; N], #[stable(feature = "rust1", since = "1.0.0")] } 39753dece8SMiguel Ojeda __impl_slice_eq1! { [A: Allocator, const N: usize] Vec<T, A>, &[U; N], #[stable(feature = "rust1", since = "1.0.0")] } 40753dece8SMiguel Ojeda 41753dece8SMiguel Ojeda // NOTE: some less important impls are omitted to reduce code bloat 42753dece8SMiguel Ojeda // FIXME(Centril): Reconsider this? 43753dece8SMiguel Ojeda //__impl_slice_eq1! { [const N: usize] Vec<A>, &mut [B; N], } 44753dece8SMiguel Ojeda //__impl_slice_eq1! { [const N: usize] [A; N], Vec<B>, } 45753dece8SMiguel Ojeda //__impl_slice_eq1! { [const N: usize] &[A; N], Vec<B>, } 46753dece8SMiguel Ojeda //__impl_slice_eq1! { [const N: usize] &mut [A; N], Vec<B>, } 47753dece8SMiguel Ojeda //__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, [B; N], } 48753dece8SMiguel Ojeda //__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], } 49753dece8SMiguel Ojeda //__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], } 50