pub struct SortExpression<T> { /* private fields */ }Expand description
One key of a sort: a value read from each item, and the direction (SortExpression<T>).
Deviation (DEVIATIONS.md, DynamicData): upstream holds the getter Func<T, IComparable>; Rust
has no common type of the values of different getters, so the expression is held as the
comparison of the values it reads. The values need PartialOrd; Option puts None first,
as upstream puts null first, and two values without an order (a NaN) compare as equal.
Implementations§
Source§impl<T: 'static> SortExpression<T>
impl<T: 'static> SortExpression<T>
Sourcepub fn new<V: PartialOrd + 'static>(
expression: impl Fn(&T) -> V + 'static,
direction: SortDirection,
) -> Self
pub fn new<V: PartialOrd + 'static>( expression: impl Fn(&T) -> V + 'static, direction: SortDirection, ) -> Self
The key expression in direction (SortExpression(Func<T, IComparable>, SortDirection)).
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
The key expression, ascending (SortExpression(Func<T, IComparable>)).
Source§impl<T> SortExpression<T>
impl<T> SortExpression<T>
Sourcepub fn direction(&self) -> SortDirection
pub fn direction(&self) -> SortDirection
The direction (Direction).
Sourcepub fn compare_values(&self, x: &T, y: &T) -> Ordering
pub fn compare_values(&self, x: &T, y: &T) -> Ordering
The comparison of the values that the expression reads from x and y, ascending
(Expression(x).CompareTo(Expression(y))).
Trait Implementations§
Source§impl<T> Clone for SortExpression<T>
impl<T> Clone for SortExpression<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for SortExpression<T>
impl<T> !Send for SortExpression<T>
impl<T> !Sync for SortExpression<T>
impl<T> !UnwindSafe for SortExpression<T>
impl<T> Freeze for SortExpression<T>
impl<T> Unpin for SortExpression<T>
impl<T> UnsafeUnpin for SortExpression<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