[−][src]Struct totally_ordered::TotallyOrdered
An ABI-transparent newtype wrapper around types that adds Ord + Eq to TotallyOrderable types (f32 and f64).
Methods
impl<F: TotallyOrderable> TotallyOrdered<F>
[src]
pub fn new(v: F) -> Self
[src]
Creates a wrapped value from an inner value
pub fn new_slice(s: &[F]) -> &[Self]
[src]
Creates a wrapped slice without copying data.
Not implemented as From<&[F]> for &[Self]
as
slices are always foreign.
Follows the usual borrowing rules:
let mut values = [1.0, 2.0, 3.0]; let values_to = TotallyOrdered::new_slice(&values); values[2] = 4.0; // error, can't mutate while borrowed assert_eq!(values_to[2], TotallyOrdered::new(3.0));
pub fn new_slice_mut(s: &mut [F]) -> &mut [Self]
[src]
Creates a mutable wrapped slice without copying data.
Not implemented as From<&mut [F]> for &mut [Self]
as
slices are always foreign.
Follows the usual borrowing rules:
let mut values = [3.0, 2.0, 1.0]; let values_to = TotallyOrdered::new_slice_mut(&mut values); assert_eq!(values[2], 1.0); // error, can't borrow while mutably borrowed values_to.sort();
Trait Implementations
impl<F: Clone + TotallyOrderable> Clone for TotallyOrdered<F>
[src]
fn clone(&self) -> TotallyOrdered<F>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<F: Copy + TotallyOrderable> Copy for TotallyOrdered<F>
[src]
impl<F: Debug + TotallyOrderable> Debug for TotallyOrdered<F>
[src]
impl<F: Default + TotallyOrderable> Default for TotallyOrdered<F>
[src]
fn default() -> TotallyOrdered<F>
[src]
impl<F: TotallyOrderable> Eq for TotallyOrdered<F>
[src]
impl<'a, F: TotallyOrderable> From<&'a F> for &'a TotallyOrdered<F>
[src]
fn from(v: &F) -> Self
[src]
The explicit lifetime bound ensures that both From
let mut value : f32 = 1.0; let value_to : &TotallyOrdered<_> = From::from(&value); value = 2.0; // error, can't mutate while borrowed assert_eq!(*value_to, TotallyOrdered::new(1.0));
and Into
let mut value : f32 = 1.0; let value_to : &TotallyOrdered<_> = (&value).into(); value = 2.0; // error, can't mutate while borrowed assert_eq!(*value_to, TotallyOrdered::new(1.0));
respect the lifetime of the borrow on the original value.
impl<'a, F: TotallyOrderable> From<&'a mut F> for &'a mut TotallyOrdered<F>
[src]
fn from(v: &mut F) -> Self
[src]
The explicit lifetime bound ensures that both From
let mut value : f32 = 1.0; let value_to : &mut TotallyOrdered<_> = From::from(&mut value); assert_eq!(value, 1.0); // error, can't borrow while mutably borrowed *value_to = TotallyOrdered::new(2.0);
and Into
let mut value : f32 = 1.0; let value_to : &mut TotallyOrdered<_> = (&mut value).into(); assert_eq!(value, 1.0); // error, can't borrow while mutably borrowed *value_to = TotallyOrdered::new(2.0);
respect the lifetime of the mutable borrow on the original value.
impl<F: TotallyOrderable> From<F> for TotallyOrdered<F>
[src]
impl<F: TotallyOrderable> Hash for TotallyOrdered<F>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<F: TotallyOrderable> Ord for TotallyOrdered<F>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<F: TotallyOrderable> PartialEq<TotallyOrdered<F>> for TotallyOrdered<F>
[src]
impl<F: TotallyOrderable> PartialOrd<TotallyOrdered<F>> for TotallyOrdered<F>
[src]
Auto Trait Implementations
impl<F> Send for TotallyOrdered<F> where
F: Send,
F: Send,
impl<F> Sync for TotallyOrdered<F> where
F: Sync,
F: Sync,
impl<F> Unpin for TotallyOrdered<F> where
F: Unpin,
F: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,