Skip to content

Commit 001b081

Browse files
committed
alloc: Allow comparing Boxs over different allocators
1 parent fa8762b commit 001b081

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

library/alloc/src/boxed.rs

+26-9
Original file line numberDiff line numberDiff line change
@@ -1311,39 +1311,56 @@ impl Clone for Box<str> {
13111311
}
13121312

13131313
#[stable(feature = "rust1", since = "1.0.0")]
1314-
impl<T: ?Sized + PartialEq, A: Allocator> PartialEq for Box<T, A> {
1314+
impl<T, A1, A2> PartialEq<Box<T, A2>> for Box<T, A1>
1315+
where
1316+
T: ?Sized + PartialEq,
1317+
A1: Allocator,
1318+
A2: Allocator,
1319+
{
13151320
#[inline]
1316-
fn eq(&self, other: &Self) -> bool {
1321+
fn eq(&self, other: &Box<T, A2>) -> bool {
13171322
PartialEq::eq(&**self, &**other)
13181323
}
1324+
13191325
#[inline]
1320-
fn ne(&self, other: &Self) -> bool {
1326+
fn ne(&self, other: &Box<T, A2>) -> bool {
13211327
PartialEq::ne(&**self, &**other)
13221328
}
13231329
}
1330+
13241331
#[stable(feature = "rust1", since = "1.0.0")]
1325-
impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for Box<T, A> {
1332+
impl<T, A1, A2> PartialOrd<Box<T, A2>> for Box<T, A1>
1333+
where
1334+
T: ?Sized + PartialOrd,
1335+
A1: Allocator,
1336+
A2: Allocator,
1337+
{
13261338
#[inline]
1327-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
1339+
fn partial_cmp(&self, other: &Box<T, A2>) -> Option<Ordering> {
13281340
PartialOrd::partial_cmp(&**self, &**other)
13291341
}
1342+
13301343
#[inline]
1331-
fn lt(&self, other: &Self) -> bool {
1344+
fn lt(&self, other: &Box<T, A2>) -> bool {
13321345
PartialOrd::lt(&**self, &**other)
13331346
}
1347+
13341348
#[inline]
1335-
fn le(&self, other: &Self) -> bool {
1349+
fn le(&self, other: &Box<T, A2>) -> bool {
13361350
PartialOrd::le(&**self, &**other)
13371351
}
1352+
13381353
#[inline]
1339-
fn ge(&self, other: &Self) -> bool {
1354+
fn ge(&self, other: &Box<T, A2>) -> bool {
13401355
PartialOrd::ge(&**self, &**other)
13411356
}
1357+
13421358
#[inline]
1343-
fn gt(&self, other: &Self) -> bool {
1359+
fn gt(&self, other: &Box<T, A2>) -> bool {
13441360
PartialOrd::gt(&**self, &**other)
13451361
}
13461362
}
1363+
13471364
#[stable(feature = "rust1", since = "1.0.0")]
13481365
impl<T: ?Sized + Ord, A: Allocator> Ord for Box<T, A> {
13491366
#[inline]

0 commit comments

Comments
 (0)