From 9d9841097ac8fc5e2228de61e03f57a78c0cabb7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 30 Dec 2024 08:17:02 +1100 Subject: [PATCH 1/2] Revert "Remove unnecessary methods" This reverts commit ba3876355d0d784b8cc00b99e8d35f0840f70118. Don't be lazy Tobin, do a deprecation cycle. --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index d51cffa..7c80083 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -135,6 +135,16 @@ impl Ordered { /// This allows: `let found = map.get(Ordered::from_ref(&a));` #[allow(clippy::ptr_as_ptr)] pub fn from_ref(value: &T) -> &Self { unsafe { &*(value as *const _ as *const Self) } } + + /// Returns a reference to the inner object. + /// + /// We also implement [`core::borrow::Borrow`] so this function is never explicitly needed. + pub const fn as_inner(&self) -> &T { &self.0 } + + /// Returns the inner object. + /// + /// We also implement [`core::ops::Deref`] so this function is never explicitly needed. + pub fn into_inner(self) -> T { self.0 } } impl ArbitraryOrd for &T { From b2070e67f72325d7f39dfa47833b5d2b581b45fb Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 30 Dec 2024 08:18:05 +1100 Subject: [PATCH 2/2] Deprecate unnecessary methods We implement a bunch of traits for getting at the inner field. Also, the inner field is public. The `into_inner` and `as_inner` methods are just clutter - deprecate them. --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 7c80083..81dc1ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,11 +139,13 @@ impl Ordered { /// Returns a reference to the inner object. /// /// We also implement [`core::borrow::Borrow`] so this function is never explicitly needed. + #[deprecated(since = "0.3.0", note = "use `ops::Deref` instead")] pub const fn as_inner(&self) -> &T { &self.0 } /// Returns the inner object. /// /// We also implement [`core::ops::Deref`] so this function is never explicitly needed. + #[deprecated(since = "0.3.0", note = "use `ops::Deref` instead")] pub fn into_inner(self) -> T { self.0 } }