From 8e5f4adb2712c0c8abc8b66eeb6d2159654abc64 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 30 Dec 2024 08:08:09 +1100 Subject: [PATCH] Add default generic type to ArbitraryOrd The `PartialOrd` trait uses a default generic type for the right hand side of the comparison. This is useful for example to compare an object to a foreign type. For the same reasons we should provide a default generic type to `ArbitraryOrd`. Add generic type to `ArbitraryOrd` and default to `Self`. I believe this also makes the trait object safe. --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d51cffa..b7761bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,9 +82,9 @@ use core::ops::{Deref, DerefMut}; /// } /// } /// ``` -pub trait ArbitraryOrd: Eq + PartialEq { +pub trait ArbitraryOrd: Eq + PartialEq { /// Implements a meaningless, arbitrary ordering. - fn arbitrary_cmp(&self, other: &Self) -> Ordering; + fn arbitrary_cmp(&self, other: &Rhs) -> Ordering; } /// A wrapper type that implements `PartialOrd` and `Ord`.