about summary refs log tree commit diff
path: root/library/core/src/array
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-02-05 11:07:27 +0100
committerGitHub <noreply@github.com>2024-02-05 11:07:27 +0100
commit2624bfbc0d75b61c011300cce2d73ba3766437bd (patch)
treeb9bab81c31bcd5da61f8a1f5079e737ce0495437 /library/core/src/array
parent80e8c7e125c361c40881888ba78e0bdd2ba456e9 (diff)
parent3f3a153056b0d60305f5b7d676ab2d720a91fef9 (diff)
downloadrust-2624bfbc0d75b61c011300cce2d73ba3766437bd.tar.gz
rust-2624bfbc0d75b61c011300cce2d73ba3766437bd.zip
Rollup merge of #120384 - wackbyte:array-equality-generics, r=Mark-Simulacrum
Use `<T, U>` for array/slice equality `impl`s

Makes the trait implementation documentation for arrays and slices appear more consistent.

[Example](https://doc.rust-lang.org/1.75.0/std/primitive.array.html): mixed `A`, `B`, and `U`.
![List of PartialEq implementations for arrays](https://github.com/wackbyte/rust/assets/29505620/823c010e-ee57-4de1-885b-a1cd6dcaf85f)

This change makes them all `U`.
Diffstat (limited to 'library/core/src/array')
-rw-r--r--library/core/src/array/equality.rs64
1 files changed, 32 insertions, 32 deletions
diff --git a/library/core/src/array/equality.rs b/library/core/src/array/equality.rs
index d749865f76f..bdb6599abf5 100644
--- a/library/core/src/array/equality.rs
+++ b/library/core/src/array/equality.rs
@@ -2,36 +2,36 @@ use crate::cmp::BytewiseEq;
 use crate::convert::TryInto;
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<A, B, const N: usize> PartialEq<[B; N]> for [A; N]
+impl<T, U, const N: usize> PartialEq<[U; N]> for [T; N]
 where
-    A: PartialEq<B>,
+    T: PartialEq<U>,
 {
     #[inline]
-    fn eq(&self, other: &[B; N]) -> bool {
+    fn eq(&self, other: &[U; N]) -> bool {
         SpecArrayEq::spec_eq(self, other)
     }
     #[inline]
-    fn ne(&self, other: &[B; N]) -> bool {
+    fn ne(&self, other: &[U; N]) -> bool {
         SpecArrayEq::spec_ne(self, other)
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<A, B, const N: usize> PartialEq<[B]> for [A; N]
+impl<T, U, const N: usize> PartialEq<[U]> for [T; N]
 where
-    A: PartialEq<B>,
+    T: PartialEq<U>,
 {
     #[inline]
-    fn eq(&self, other: &[B]) -> bool {
-        let b: Result<&[B; N], _> = other.try_into();
+    fn eq(&self, other: &[U]) -> bool {
+        let b: Result<&[U; N], _> = other.try_into();
         match b {
             Ok(b) => *self == *b,
             Err(_) => false,
         }
     }
     #[inline]
-    fn ne(&self, other: &[B]) -> bool {
-        let b: Result<&[B; N], _> = other.try_into();
+    fn ne(&self, other: &[U]) -> bool {
+        let b: Result<&[U; N], _> = other.try_into();
         match b {
             Ok(b) => *self != *b,
             Err(_) => true,
@@ -40,21 +40,21 @@ where
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<A, B, const N: usize> PartialEq<[A; N]> for [B]
+impl<T, U, const N: usize> PartialEq<[U; N]> for [T]
 where
-    B: PartialEq<A>,
+    T: PartialEq<U>,
 {
     #[inline]
-    fn eq(&self, other: &[A; N]) -> bool {
-        let b: Result<&[B; N], _> = self.try_into();
+    fn eq(&self, other: &[U; N]) -> bool {
+        let b: Result<&[T; N], _> = self.try_into();
         match b {
             Ok(b) => *b == *other,
             Err(_) => false,
         }
     }
     #[inline]
-    fn ne(&self, other: &[A; N]) -> bool {
-        let b: Result<&[B; N], _> = self.try_into();
+    fn ne(&self, other: &[U; N]) -> bool {
+        let b: Result<&[T; N], _> = self.try_into();
         match b {
             Ok(b) => *b != *other,
             Err(_) => true,
@@ -63,61 +63,61 @@ where
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<A, B, const N: usize> PartialEq<&[B]> for [A; N]
+impl<T, U, const N: usize> PartialEq<&[U]> for [T; N]
 where
-    A: PartialEq<B>,
+    T: PartialEq<U>,
 {
     #[inline]
-    fn eq(&self, other: &&[B]) -> bool {
+    fn eq(&self, other: &&[U]) -> bool {
         *self == **other
     }
     #[inline]
-    fn ne(&self, other: &&[B]) -> bool {
+    fn ne(&self, other: &&[U]) -> bool {
         *self != **other
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<A, B, const N: usize> PartialEq<[A; N]> for &[B]
+impl<T, U, const N: usize> PartialEq<[U; N]> for &[T]
 where
-    B: PartialEq<A>,
+    T: PartialEq<U>,
 {
     #[inline]
-    fn eq(&self, other: &[A; N]) -> bool {
+    fn eq(&self, other: &[U; N]) -> bool {
         **self == *other
     }
     #[inline]
-    fn ne(&self, other: &[A; N]) -> bool {
+    fn ne(&self, other: &[U; N]) -> bool {
         **self != *other
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<A, B, const N: usize> PartialEq<&mut [B]> for [A; N]
+impl<T, U, const N: usize> PartialEq<&mut [U]> for [T; N]
 where
-    A: PartialEq<B>,
+    T: PartialEq<U>,
 {
     #[inline]
-    fn eq(&self, other: &&mut [B]) -> bool {
+    fn eq(&self, other: &&mut [U]) -> bool {
         *self == **other
     }
     #[inline]
-    fn ne(&self, other: &&mut [B]) -> bool {
+    fn ne(&self, other: &&mut [U]) -> bool {
         *self != **other
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<A, B, const N: usize> PartialEq<[A; N]> for &mut [B]
+impl<T, U, const N: usize> PartialEq<[U; N]> for &mut [T]
 where
-    B: PartialEq<A>,
+    T: PartialEq<U>,
 {
     #[inline]
-    fn eq(&self, other: &[A; N]) -> bool {
+    fn eq(&self, other: &[U; N]) -> bool {
         **self == *other
     }
     #[inline]
-    fn ne(&self, other: &[A; N]) -> bool {
+    fn ne(&self, other: &[U; N]) -> bool {
         **self != *other
     }
 }