|
56 | 56 |
|
57 | 57 | #![stable(feature = "rust1", since = "1.0.0")]
|
58 | 58 |
|
| 59 | +use core::array::LengthAtMost32; |
59 | 60 | use core::cmp::{self, Ordering};
|
60 | 61 | use core::fmt;
|
61 | 62 | use core::hash::{self, Hash};
|
@@ -2171,47 +2172,36 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for Vec<T> {
|
2171 | 2172 | }
|
2172 | 2173 |
|
2173 | 2174 | macro_rules! __impl_slice_eq1 {
|
2174 |
| - ($Lhs: ty, $Rhs: ty) => { |
2175 |
| - __impl_slice_eq1! { $Lhs, $Rhs, Sized } |
2176 |
| - }; |
2177 |
| - ($Lhs: ty, $Rhs: ty, $Bound: ident) => { |
| 2175 | + ([$($vars:tt)*] $lhs:ty, $rhs:ty, $($constraints:tt)*) => { |
2178 | 2176 | #[stable(feature = "rust1", since = "1.0.0")]
|
2179 |
| - impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> { |
| 2177 | + impl<A, B, $($vars)*> PartialEq<$rhs> for $lhs |
| 2178 | + where |
| 2179 | + A: PartialEq<B>, |
| 2180 | + $($constraints)* |
| 2181 | + { |
2180 | 2182 | #[inline]
|
2181 |
| - fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] } |
| 2183 | + fn eq(&self, other: &$rhs) -> bool { self[..] == other[..] } |
2182 | 2184 | #[inline]
|
2183 |
| - fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] } |
| 2185 | + fn ne(&self, other: &$rhs) -> bool { self[..] != other[..] } |
2184 | 2186 | }
|
2185 | 2187 | }
|
2186 | 2188 | }
|
2187 | 2189 |
|
2188 |
| -__impl_slice_eq1! { Vec<A>, Vec<B> } |
2189 |
| -__impl_slice_eq1! { Vec<A>, &'b [B] } |
2190 |
| -__impl_slice_eq1! { Vec<A>, &'b mut [B] } |
2191 |
| -__impl_slice_eq1! { Cow<'a, [A]>, &'b [B], Clone } |
2192 |
| -__impl_slice_eq1! { Cow<'a, [A]>, &'b mut [B], Clone } |
2193 |
| -__impl_slice_eq1! { Cow<'a, [A]>, Vec<B>, Clone } |
| 2190 | +__impl_slice_eq1! { [] Vec<A>, Vec<B>, } |
| 2191 | +__impl_slice_eq1! { [] Vec<A>, &[B], } |
| 2192 | +__impl_slice_eq1! { [] Vec<A>, &mut [B], } |
| 2193 | +__impl_slice_eq1! { [] Cow<'_, [A]>, &[B], A: Clone } |
| 2194 | +__impl_slice_eq1! { [] Cow<'_, [A]>, &mut [B], A: Clone } |
| 2195 | +__impl_slice_eq1! { [] Cow<'_, [A]>, Vec<B>, A: Clone } |
| 2196 | +__impl_slice_eq1! { [const N: usize] Vec<A>, [B; N], [B; N]: LengthAtMost32 } |
| 2197 | +__impl_slice_eq1! { [const N: usize] Vec<A>, &[B; N], [B; N]: LengthAtMost32 } |
2194 | 2198 |
|
2195 |
| -macro_rules! array_impls { |
2196 |
| - ($($N: expr)+) => { |
2197 |
| - $( |
2198 |
| - // NOTE: some less important impls are omitted to reduce code bloat |
2199 |
| - __impl_slice_eq1! { Vec<A>, [B; $N] } |
2200 |
| - __impl_slice_eq1! { Vec<A>, &'b [B; $N] } |
2201 |
| - // __impl_slice_eq1! { Vec<A>, &'b mut [B; $N] } |
2202 |
| - // __impl_slice_eq1! { Cow<'a, [A]>, [B; $N], Clone } |
2203 |
| - // __impl_slice_eq1! { Cow<'a, [A]>, &'b [B; $N], Clone } |
2204 |
| - // __impl_slice_eq1! { Cow<'a, [A]>, &'b mut [B; $N], Clone } |
2205 |
| - )+ |
2206 |
| - } |
2207 |
| -} |
2208 |
| - |
2209 |
| -array_impls! { |
2210 |
| - 0 1 2 3 4 5 6 7 8 9 |
2211 |
| - 10 11 12 13 14 15 16 17 18 19 |
2212 |
| - 20 21 22 23 24 25 26 27 28 29 |
2213 |
| - 30 31 32 |
2214 |
| -} |
| 2199 | +// NOTE: some less important impls are omitted to reduce code bloat |
| 2200 | +// FIXME(Centril): Reconsider this? |
| 2201 | +//__impl_slice_eq1! { [const N: usize] Vec<A>, &mut [B; N], [B; N]: LengthAtMost32 } |
| 2202 | +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, [B; N], [B; N]: LengthAtMost32 } |
| 2203 | +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], [B; N]: LengthAtMost32 } |
| 2204 | +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], [B; N]: LengthAtMost32 } |
2215 | 2205 |
|
2216 | 2206 | /// Implements comparison of vectors, lexicographically.
|
2217 | 2207 | #[stable(feature = "rust1", since = "1.0.0")]
|
|
0 commit comments