Skip to content

Commit fc984cb

Browse files
authored
Add PartialEq impls to mirror the stdlib (#358)
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
1 parent 1dd57a4 commit fc984cb

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/lib.rs

+50
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,56 @@ where
20202020
}
20212021
impl<T, const N: usize> Eq for SmallVec<T, N> where T: Eq {}
20222022

2023+
impl<T, U, const N: usize, const M: usize> PartialEq<[U; M]> for SmallVec<T, N>
2024+
where
2025+
T: PartialEq<U>,
2026+
{
2027+
#[inline]
2028+
fn eq(&self, other: &[U; M]) -> bool {
2029+
self[..] == other[..]
2030+
}
2031+
}
2032+
2033+
impl<T, U, const N: usize, const M: usize> PartialEq<&[U; M]> for SmallVec<T, N>
2034+
where
2035+
T: PartialEq<U>,
2036+
{
2037+
#[inline]
2038+
fn eq(&self, other: &&[U; M]) -> bool {
2039+
self[..] == other[..]
2040+
}
2041+
}
2042+
2043+
impl<T, U, const N: usize> PartialEq<[U]> for SmallVec<T, N>
2044+
where
2045+
T: PartialEq<U>,
2046+
{
2047+
#[inline]
2048+
fn eq(&self, other: &[U]) -> bool {
2049+
self[..] == other[..]
2050+
}
2051+
}
2052+
2053+
impl<T, U, const N: usize> PartialEq<&[U]> for SmallVec<T, N>
2054+
where
2055+
T: PartialEq<U>,
2056+
{
2057+
#[inline]
2058+
fn eq(&self, other: &&[U]) -> bool {
2059+
self[..] == other[..]
2060+
}
2061+
}
2062+
2063+
impl<T, U, const N: usize> PartialEq<&mut [U]> for SmallVec<T, N>
2064+
where
2065+
T: PartialEq<U>,
2066+
{
2067+
#[inline]
2068+
fn eq(&self, other: &&mut [U]) -> bool {
2069+
self[..] == other[..]
2070+
}
2071+
}
2072+
20232073
impl<T, const N: usize> PartialOrd for SmallVec<T, N>
20242074
where
20252075
T: PartialOrd,

0 commit comments

Comments
 (0)