SortExpressionComparer
struct · ferroui-dynamic-data · v0.5.0
struct SortExpressionComparer<T>
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().
Members
ascending
fn ascending<V: PartialOrd + 'static>(expression: impl Fn(&T) -> V + 'static) -> Self
A comparer by expression, ascending (SortExpressionComparer<T>.Ascending).
descending
fn descending<V: PartialOrd + 'static>(expression: impl Fn(&T) -> V + 'static) -> Self
A comparer by expression, descending (SortExpressionComparer<T>.Descending).
then_by_ascending
fn then_by_ascending<V: PartialOrd + 'static>(self: Self, expression: impl Fn(&T) -> V + 'static) -> Self
The comparer, then by expression, ascending (ThenByAscending).
then_by_descending
fn then_by_descending<V: PartialOrd + 'static>(self: Self, expression: impl Fn(&T) -> V + 'static) -> Self
The comparer, then by expression, descending (ThenByDescending).
comparer
fn comparer(self: &Self) -> Rc<dyn Fn(&T, &T) -> Ordering>
The comparer as the function that the operators take (IComparer<T>).
push
fn push(self: &mut Self, expression: SortExpression<T>)
Adds a key (Add, of the list upstream's comparer is).
expressions
fn expressions(self: &Self) -> &[SortExpression<T>]
The keys, in order.
compare
fn compare(self: &Self, x: &T, y: &T) -> Ordering
Compares x and y by the keys in order (Compare).
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedCloneDefaultDebugFrom<SortExpressionComparer<T>>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.