diff options
| author | Igor Gutorov <igootorov@gmail.com> | 2023-06-14 19:50:32 +0300 |
|---|---|---|
| committer | Igor Gutorov <igootorov@gmail.com> | 2023-06-18 06:19:35 +0300 |
| commit | 001b081cc1bfd24657e2dccbd9c8289f9a9d67a5 (patch) | |
| tree | 93553bdf3538dccd6584e5b731f333c2563ef449 | |
| parent | fa8762b7b6c2b75d6c83fb011ee8fa4874168829 (diff) | |
| download | rust-001b081cc1bfd24657e2dccbd9c8289f9a9d67a5.tar.gz rust-001b081cc1bfd24657e2dccbd9c8289f9a9d67a5.zip | |
alloc: Allow comparing `Box`s over different allocators
| -rw-r--r-- | library/alloc/src/boxed.rs | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 1768687e8cd..ce0d19f1a3c 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -1311,39 +1311,56 @@ impl Clone for Box<str> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: ?Sized + PartialEq, A: Allocator> PartialEq for Box<T, A> { +impl<T, A1, A2> PartialEq<Box<T, A2>> for Box<T, A1> +where + T: ?Sized + PartialEq, + A1: Allocator, + A2: Allocator, +{ #[inline] - fn eq(&self, other: &Self) -> bool { + fn eq(&self, other: &Box<T, A2>) -> bool { PartialEq::eq(&**self, &**other) } + #[inline] - fn ne(&self, other: &Self) -> bool { + fn ne(&self, other: &Box<T, A2>) -> bool { PartialEq::ne(&**self, &**other) } } + #[stable(feature = "rust1", since = "1.0.0")] -impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for Box<T, A> { +impl<T, A1, A2> PartialOrd<Box<T, A2>> for Box<T, A1> +where + T: ?Sized + PartialOrd, + A1: Allocator, + A2: Allocator, +{ #[inline] - fn partial_cmp(&self, other: &Self) -> Option<Ordering> { + fn partial_cmp(&self, other: &Box<T, A2>) -> Option<Ordering> { PartialOrd::partial_cmp(&**self, &**other) } + #[inline] - fn lt(&self, other: &Self) -> bool { + fn lt(&self, other: &Box<T, A2>) -> bool { PartialOrd::lt(&**self, &**other) } + #[inline] - fn le(&self, other: &Self) -> bool { + fn le(&self, other: &Box<T, A2>) -> bool { PartialOrd::le(&**self, &**other) } + #[inline] - fn ge(&self, other: &Self) -> bool { + fn ge(&self, other: &Box<T, A2>) -> bool { PartialOrd::ge(&**self, &**other) } + #[inline] - fn gt(&self, other: &Self) -> bool { + fn gt(&self, other: &Box<T, A2>) -> bool { PartialOrd::gt(&**self, &**other) } } + #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + Ord, A: Allocator> Ord for Box<T, A> { #[inline] |
