Skip to content

Commit a5dbf8a

Browse files
authored
Auto merge of #36310 - jstnlef:remove-extraneous-not-equal-impl, r=sfackler
Removing the extraneous not_equal implementation for slices Happened to stumble upon this one awhile back. Seemed a bit silly to have both the equals and not equals implementation when they're so similar.
2 parents 4a26286 + a77b55d commit a5dbf8a

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/libcore/slice.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,8 @@ impl<T: PartialOrd> PartialOrd for [T] {
18211821
// intermediate trait for specialization of slice's PartialEq
18221822
trait SlicePartialEq<B> {
18231823
fn equal(&self, other: &[B]) -> bool;
1824-
fn not_equal(&self, other: &[B]) -> bool;
1824+
1825+
fn not_equal(&self, other: &[B]) -> bool { !self.equal(other) }
18251826
}
18261827

18271828
// Generic slice equality
@@ -1841,20 +1842,6 @@ impl<A, B> SlicePartialEq<B> for [A]
18411842

18421843
true
18431844
}
1844-
1845-
default fn not_equal(&self, other: &[B]) -> bool {
1846-
if self.len() != other.len() {
1847-
return true;
1848-
}
1849-
1850-
for i in 0..self.len() {
1851-
if self[i].ne(&other[i]) {
1852-
return true;
1853-
}
1854-
}
1855-
1856-
false
1857-
}
18581845
}
18591846

18601847
// Use memcmp for bytewise equality when the types allow
@@ -1874,10 +1861,6 @@ impl<A> SlicePartialEq<A> for [A]
18741861
other.as_ptr() as *const u8, size) == 0
18751862
}
18761863
}
1877-
1878-
fn not_equal(&self, other: &[A]) -> bool {
1879-
!self.equal(other)
1880-
}
18811864
}
18821865

18831866
#[doc(hidden)]

0 commit comments

Comments
 (0)