1#[cfg(not(no_global_oom_handling))]
2use alloc_crate::borrow::Cow;
3
4use crate::stable::alloc::Allocator;
5
6use super::Vec;
7
8macro_rules! __impl_slice_eq1 {
9 ([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?) => {
10 impl<T, U, $($vars)*> PartialEq<$rhs> for $lhs
11 where
12 T: PartialEq<U>,
13 $($ty: $bound)?
14 {
15 #[inline(always)]
16 fn eq(&self, other: &$rhs) -> bool { self[..] == other[..] }
17 #[inline(always)]
18 fn ne(&self, other: &$rhs) -> bool { self[..] != other[..] }
19 }
20 }
21}
22
23__impl_slice_eq1! { [A1: Allocator, A2: Allocator] Vec<T, A1>, Vec<U, A2> }
24__impl_slice_eq1! { [A: Allocator] Vec<T, A>, &[U] }
25__impl_slice_eq1! { [A: Allocator] Vec<T, A>, &mut [U] }
26__impl_slice_eq1! { [A: Allocator] &[T], Vec<U, A> }
27__impl_slice_eq1! { [A: Allocator] &mut [T], Vec<U, A> }
28__impl_slice_eq1! { [A: Allocator] Vec<T, A>, [U] }
29__impl_slice_eq1! { [A: Allocator] [T], Vec<U, A> }
30#[cfg(not(no_global_oom_handling))]
31__impl_slice_eq1! { [A: Allocator] Cow<'_, [T]>, Vec<U, A> where T: Clone }
32__impl_slice_eq1! { [A: Allocator, const N: usize] Vec<T, A>, [U; N] }
33__impl_slice_eq1! { [A: Allocator, const N: usize] Vec<T, A>, &[U; N] }
34
35// NOTE: some less important impls are omitted to reduce code bloat
36// FIXME(Centril): Reconsider this?
37//__impl_slice_eq1! { [const N: usize] Vec<A>, &mut [B; N], }
38//__impl_slice_eq1! { [const N: usize] [A; N], Vec<B>, }
39//__impl_slice_eq1! { [const N: usize] &[A; N], Vec<B>, }
40//__impl_slice_eq1! { [const N: usize] &mut [A; N], Vec<B>, }
41//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, [B; N], }
42//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], }
43//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], }
44