pub struct SortExpressionComparer<T> { /* private fields */ }Expand description
A comparer of items by a list of keys, each ascending or descending
(SortExpressionComparer<T>): the first key that differs decides.
It builds as upstream’s does, SortExpressionComparer::ascending(|p: &Person| p.age()) .then_by_ascending(|p| p.name()), and becomes the comparer that the operators take,
Rc<dyn Fn(&T, &T) -> Ordering>, with comparer or into().
Implementations§
Source§impl<T: 'static> SortExpressionComparer<T>
impl<T: 'static> SortExpressionComparer<T>
Sourcepub fn ascending<V: PartialOrd + 'static>(
expression: impl Fn(&T) -> V + 'static,
) -> Self
pub fn ascending<V: PartialOrd + 'static>( expression: impl Fn(&T) -> V + 'static, ) -> Self
A comparer by expression, ascending (SortExpressionComparer<T>.Ascending).
Sourcepub fn descending<V: PartialOrd + 'static>(
expression: impl Fn(&T) -> V + 'static,
) -> Self
pub fn descending<V: PartialOrd + 'static>( expression: impl Fn(&T) -> V + 'static, ) -> Self
A comparer by expression, descending (SortExpressionComparer<T>.Descending).
Sourcepub fn then_by_ascending<V: PartialOrd + 'static>(
self,
expression: impl Fn(&T) -> V + 'static,
) -> Self
pub fn then_by_ascending<V: PartialOrd + 'static>( self, expression: impl Fn(&T) -> V + 'static, ) -> Self
The comparer, then by expression, ascending (ThenByAscending).
Sourcepub fn then_by_descending<V: PartialOrd + 'static>(
self,
expression: impl Fn(&T) -> V + 'static,
) -> Self
pub fn then_by_descending<V: PartialOrd + 'static>( self, expression: impl Fn(&T) -> V + 'static, ) -> Self
The comparer, then by expression, descending (ThenByDescending).
Source§impl<T> SortExpressionComparer<T>
impl<T> SortExpressionComparer<T>
Sourcepub fn push(&mut self, expression: SortExpression<T>)
pub fn push(&mut self, expression: SortExpression<T>)
Adds a key (Add, of the list upstream’s comparer is).
Sourcepub fn expressions(&self) -> &[SortExpression<T>]
pub fn expressions(&self) -> &[SortExpression<T>]
The keys, in order.
Trait Implementations§
Source§impl<T> Clone for SortExpressionComparer<T>
impl<T> Clone for SortExpressionComparer<T>
Source§impl<T> Debug for SortExpressionComparer<T>
impl<T> Debug for SortExpressionComparer<T>
Source§impl<T> Default for SortExpressionComparer<T>
impl<T> Default for SortExpressionComparer<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for SortExpressionComparer<T>
impl<T> !Send for SortExpressionComparer<T>
impl<T> !Sync for SortExpressionComparer<T>
impl<T> !UnwindSafe for SortExpressionComparer<T>
impl<T> Freeze for SortExpressionComparer<T>
impl<T> Unpin for SortExpressionComparer<T>
impl<T> UnsafeUnpin for SortExpressionComparer<T>
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