pub struct Natural<T: Ord + ?Sized>(/* private fields */);
Expand description
A comparator that delegates to Ord
(http://doc.rust-lang.org/std/cmp/trait.Ord.html).
§Examples
use compare::{Compare, natural};
use std::cmp::Ordering::{Less, Equal, Greater};
let a = &1;
let b = &2;
let cmp = natural();
assert_eq!(cmp.compare(a, b), Less);
assert_eq!(cmp.compare(b, a), Greater);
assert_eq!(cmp.compare(a, a), Equal);
Trait Implementations§
Source§impl<T: Ord + ?Sized> Compare<T> for Natural<T>
impl<T: Ord + ?Sized> Compare<T> for Natural<T>
Source§fn compare(&self, l: &T, r: &T) -> Ordering
fn compare(&self, l: &T, r: &T) -> Ordering
Compares two values, returning
Less
, Equal
, or Greater
if l
is less
than, equal to, or greater than r
, respectively.Source§fn borrowing(self) -> Borrowing<Self, L, R>where
Self: Sized,
fn borrowing(self) -> Borrowing<Self, L, R>where
Self: Sized,
Borrows the comparator’s parameters before comparing them. Read more
Source§fn rev(self) -> Rev<Self>where
Self: Sized,
fn rev(self) -> Rev<Self>where
Self: Sized,
Reverses the ordering of the comparator. Read more
impl<T: Ord + ?Sized> Copy for Natural<T>
impl<T: Ord + ?Sized> Eq for Natural<T>
Auto Trait Implementations§
impl<T> Freeze for Natural<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Natural<T>where
T: ?Sized,
impl<T> Send for Natural<T>where
T: ?Sized,
impl<T> Sync for Natural<T>where
T: ?Sized,
impl<T> Unpin for Natural<T>where
T: ?Sized,
impl<T> UnwindSafe for Natural<T>where
T: ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more