Skip to content

Commit 8d647dd

Browse files
committed
Put constructor first
Put the constructor method above the getters. Code move only.
1 parent c6ac14b commit 8d647dd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ impl<T> Ordered<T> {
112112
/// The inner type is public so this function is never explicitly needed.
113113
pub const fn new(inner: T) -> Self { Self(inner) }
114114

115+
/// Creates an `Ordered<T>` from a reference.
116+
///
117+
/// This allows: `let found = map.get(Ordered::from_ref(&a));`
118+
#[allow(clippy::ptr_as_ptr)]
119+
pub fn from_ref(value: &T) -> &Self { unsafe { &*(value as *const _ as *const Self) } }
120+
115121
/// Returns a reference to the inner object.
116122
///
117123
/// We also implement [`core::borrow::Borrow`] so this function is never explicitly needed.
@@ -121,12 +127,6 @@ impl<T> Ordered<T> {
121127
///
122128
/// We also implement [`core::ops::Deref`] so this function is never explicitly needed.
123129
pub fn into_inner(self) -> T { self.0 }
124-
125-
/// Creates an `Ordered<T>` from a reference.
126-
///
127-
/// This allows: `let found = map.get(Ordered::from_ref(&a));`
128-
#[allow(clippy::ptr_as_ptr)]
129-
pub fn from_ref(value: &T) -> &Self { unsafe { &*(value as *const _ as *const Self) } }
130130
}
131131

132132
impl<T: ArbitraryOrd> ArbitraryOrd for &T {

0 commit comments

Comments
 (0)