pub struct Order<'x, T> { /* private fields */ }
Implementations§
Source§impl<'x, T> Order<'x, T>
impl<'x, T> Order<'x, T>
pub fn new(a: &'x T, b: &'x T) -> Self
pub fn by<F>(self, f: F) -> Self
pub fn reverse_by<F>(self, f: F) -> Self
pub fn by_key<F, U>(self, f: F) -> Self
Sourcepub fn reverse_by_key<F, U>(self, f: F) -> Self
pub fn reverse_by_key<F, U>(self, f: F) -> Self
Examples found in repository?
examples/people.rs (line 17)
3fn main() {
4 let mut people = vec![
5 // Please PR better a better example if you can think of one 😅
6 Person::new("Michael", "Foo", 24),
7 Person::new("Michael", "Foo", 10),
8 Person::new("Jeff", "Bar", 25),
9 Person::new("Maria", "Foo", 25),
10 Person::new("Maria", "Bar", 26),
11 ];
12
13 #[rustfmt::skip]
14 people.rearrange(|order| order
15 .by_ref(|p| &p.last_name)
16 .by_ref(|p| &p.first_name)
17 .reverse_by_key(|p| p.age)
18 );
19
20 for person in people {
21 println!(
22 "{} {} ({})",
23 person.first_name, person.last_name, person.age
24 );
25 }
26}
Sourcepub fn by_ref<F, U>(self, f: F) -> Self
pub fn by_ref<F, U>(self, f: F) -> Self
Examples found in repository?
examples/people.rs (line 15)
3fn main() {
4 let mut people = vec![
5 // Please PR better a better example if you can think of one 😅
6 Person::new("Michael", "Foo", 24),
7 Person::new("Michael", "Foo", 10),
8 Person::new("Jeff", "Bar", 25),
9 Person::new("Maria", "Foo", 25),
10 Person::new("Maria", "Bar", 26),
11 ];
12
13 #[rustfmt::skip]
14 people.rearrange(|order| order
15 .by_ref(|p| &p.last_name)
16 .by_ref(|p| &p.first_name)
17 .reverse_by_key(|p| p.age)
18 );
19
20 for person in people {
21 println!(
22 "{} {} ({})",
23 person.first_name, person.last_name, person.age
24 );
25 }
26}
pub fn reverse_by_ref<F, U>(self, f: F) -> Self
pub fn ordering(&self) -> Ordering
Auto Trait Implementations§
impl<'x, T> Freeze for Order<'x, T>
impl<'x, T> RefUnwindSafe for Order<'x, T>where
T: RefUnwindSafe,
impl<'x, T> Send for Order<'x, T>where
T: Sync,
impl<'x, T> Sync for Order<'x, T>where
T: Sync,
impl<'x, T> Unpin for Order<'x, T>
impl<'x, T> UnwindSafe for Order<'x, T>where
T: RefUnwindSafe,
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