[][src]Struct totally_ordered::TotallyOrdered

#[repr(transparent)]
pub struct TotallyOrdered<F: TotallyOrderable>(pub F);

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:

This example deliberately fails to compile
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:

This example deliberately fails to compile
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]

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]

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

This example deliberately fails to compile
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

This example deliberately fails to compile
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

This example deliberately fails to compile
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

This example deliberately fails to compile
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]

impl<F: TotallyOrderable> Ord for TotallyOrdered<F>[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

impl<F> Sync for TotallyOrdered<F> where
    F: Sync

impl<F> Unpin for TotallyOrdered<F> where
    F: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[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]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.