Skip to content

Commit 83cda47

Browse files
authored
Use <T, U> for array equality impls
Makes the trait implementation documentation for arrays appear more consistent.
1 parent cdd4ff8 commit 83cda47

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

library/core/src/array/equality.rs

+32-32
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@ use crate::cmp::BytewiseEq;
22
use crate::convert::TryInto;
33

44
#[stable(feature = "rust1", since = "1.0.0")]
5-
impl<A, B, const N: usize> PartialEq<[B; N]> for [A; N]
5+
impl<T, U, const N: usize> PartialEq<[U; N]> for [T; N]
66
where
7-
A: PartialEq<B>,
7+
T: PartialEq<U>,
88
{
99
#[inline]
10-
fn eq(&self, other: &[B; N]) -> bool {
10+
fn eq(&self, other: &[U; N]) -> bool {
1111
SpecArrayEq::spec_eq(self, other)
1212
}
1313
#[inline]
14-
fn ne(&self, other: &[B; N]) -> bool {
14+
fn ne(&self, other: &[U; N]) -> bool {
1515
SpecArrayEq::spec_ne(self, other)
1616
}
1717
}
1818

1919
#[stable(feature = "rust1", since = "1.0.0")]
20-
impl<A, B, const N: usize> PartialEq<[B]> for [A; N]
20+
impl<T, U, const N: usize> PartialEq<[U]> for [T; N]
2121
where
22-
A: PartialEq<B>,
22+
T: PartialEq<U>,
2323
{
2424
#[inline]
25-
fn eq(&self, other: &[B]) -> bool {
26-
let b: Result<&[B; N], _> = other.try_into();
25+
fn eq(&self, other: &[U]) -> bool {
26+
let b: Result<&[U; N], _> = other.try_into();
2727
match b {
2828
Ok(b) => *self == *b,
2929
Err(_) => false,
3030
}
3131
}
3232
#[inline]
33-
fn ne(&self, other: &[B]) -> bool {
34-
let b: Result<&[B; N], _> = other.try_into();
33+
fn ne(&self, other: &[U]) -> bool {
34+
let b: Result<&[U; N], _> = other.try_into();
3535
match b {
3636
Ok(b) => *self != *b,
3737
Err(_) => true,
@@ -40,21 +40,21 @@ where
4040
}
4141

4242
#[stable(feature = "rust1", since = "1.0.0")]
43-
impl<A, B, const N: usize> PartialEq<[A; N]> for [B]
43+
impl<T, U, const N: usize> PartialEq<[U; N]> for [T]
4444
where
45-
B: PartialEq<A>,
45+
T: PartialEq<U>,
4646
{
4747
#[inline]
48-
fn eq(&self, other: &[A; N]) -> bool {
49-
let b: Result<&[B; N], _> = self.try_into();
48+
fn eq(&self, other: &[U; N]) -> bool {
49+
let b: Result<&[T; N], _> = self.try_into();
5050
match b {
5151
Ok(b) => *b == *other,
5252
Err(_) => false,
5353
}
5454
}
5555
#[inline]
56-
fn ne(&self, other: &[A; N]) -> bool {
57-
let b: Result<&[B; N], _> = self.try_into();
56+
fn ne(&self, other: &[U; N]) -> bool {
57+
let b: Result<&[T; N], _> = self.try_into();
5858
match b {
5959
Ok(b) => *b != *other,
6060
Err(_) => true,
@@ -63,61 +63,61 @@ where
6363
}
6464

6565
#[stable(feature = "rust1", since = "1.0.0")]
66-
impl<A, B, const N: usize> PartialEq<&[B]> for [A; N]
66+
impl<T, U, const N: usize> PartialEq<&[U]> for [T; N]
6767
where
68-
A: PartialEq<B>,
68+
T: PartialEq<U>,
6969
{
7070
#[inline]
71-
fn eq(&self, other: &&[B]) -> bool {
71+
fn eq(&self, other: &&[U]) -> bool {
7272
*self == **other
7373
}
7474
#[inline]
75-
fn ne(&self, other: &&[B]) -> bool {
75+
fn ne(&self, other: &&[U]) -> bool {
7676
*self != **other
7777
}
7878
}
7979

8080
#[stable(feature = "rust1", since = "1.0.0")]
81-
impl<A, B, const N: usize> PartialEq<[A; N]> for &[B]
81+
impl<T, U, const N: usize> PartialEq<[U; N]> for &[T]
8282
where
83-
B: PartialEq<A>,
83+
T: PartialEq<U>,
8484
{
8585
#[inline]
86-
fn eq(&self, other: &[A; N]) -> bool {
86+
fn eq(&self, other: &[U; N]) -> bool {
8787
**self == *other
8888
}
8989
#[inline]
90-
fn ne(&self, other: &[A; N]) -> bool {
90+
fn ne(&self, other: &[U; N]) -> bool {
9191
**self != *other
9292
}
9393
}
9494

9595
#[stable(feature = "rust1", since = "1.0.0")]
96-
impl<A, B, const N: usize> PartialEq<&mut [B]> for [A; N]
96+
impl<T, U, const N: usize> PartialEq<&mut [U]> for [T; N]
9797
where
98-
A: PartialEq<B>,
98+
T: PartialEq<U>,
9999
{
100100
#[inline]
101-
fn eq(&self, other: &&mut [B]) -> bool {
101+
fn eq(&self, other: &&mut [U]) -> bool {
102102
*self == **other
103103
}
104104
#[inline]
105-
fn ne(&self, other: &&mut [B]) -> bool {
105+
fn ne(&self, other: &&mut [U]) -> bool {
106106
*self != **other
107107
}
108108
}
109109

110110
#[stable(feature = "rust1", since = "1.0.0")]
111-
impl<A, B, const N: usize> PartialEq<[A; N]> for &mut [B]
111+
impl<T, U, const N: usize> PartialEq<[U; N]> for &mut [T]
112112
where
113-
B: PartialEq<A>,
113+
T: PartialEq<U>,
114114
{
115115
#[inline]
116-
fn eq(&self, other: &[A; N]) -> bool {
116+
fn eq(&self, other: &[U; N]) -> bool {
117117
**self == *other
118118
}
119119
#[inline]
120-
fn ne(&self, other: &[A; N]) -> bool {
120+
fn ne(&self, other: &[U; N]) -> bool {
121121
**self != *other
122122
}
123123
}

0 commit comments

Comments
 (0)