Skip to content

Commit 356ee33

Browse files
Rollup merge of rust-lang#112632 - gootorov:vec_alloc_partialeq, r=dtolnay
Implement PartialOrd for `Vec`s over different allocators It is already possible to `PartialEq` `Vec`s with different allocators, but that is not the case with `PartialOrd`.
2 parents e7b7b7f + ed82c05 commit 356ee33

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

library/alloc/src/vec/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -2978,9 +2978,14 @@ impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> {
29782978

29792979
/// Implements comparison of vectors, [lexicographically](Ord#lexicographical-comparison).
29802980
#[stable(feature = "rust1", since = "1.0.0")]
2981-
impl<T: PartialOrd, A: Allocator> PartialOrd for Vec<T, A> {
2981+
impl<T, A1, A2> PartialOrd<Vec<T, A2>> for Vec<T, A1>
2982+
where
2983+
T: PartialOrd,
2984+
A1: Allocator,
2985+
A2: Allocator,
2986+
{
29822987
#[inline]
2983-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
2988+
fn partial_cmp(&self, other: &Vec<T, A2>) -> Option<Ordering> {
29842989
PartialOrd::partial_cmp(&**self, &**other)
29852990
}
29862991
}

0 commit comments

Comments
 (0)