FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    OrderedComparer

    struct · ferroui-reactiveui · v0.5.0

    struct OrderedComparer<T>
    

    The starting point of a chain of comparers of T (OrderedComparer<T> and the non-generic OrderedComparer): the first key of the order, which then_by extends.

    Deviation (DEVIATIONS.md, ReactiveUI): upstream's generic and non-generic static classes share the name; here they are the functions of one type, the For functions of the non-generic class being for_items and for_type. A comparer is a shared comparison function (Comparer), as IComparer<T> is in the rest of the port.

    use ferroui_reactiveui::{ComparerChainingExtensions, OrderedComparer};
    
    let mut words = vec!["bb", "a", "ab", "b"];
    let comparer = OrderedComparer::<&str>::order_by(|word| word.len()).then_by(|word| word.to_string());
    words.sort_by(|x, y| comparer(x, y));
    assert_eq!(words, vec!["a", "b", "ab", "bb"]);
    

    View source

    Members

    for_items

    fn for_items(_items: &[T]) -> OrderedComparerTypeWrapper<T>
    

    The builder of comparers of the elements of items, whose type it infers; useful for the types that have no name, such as tuples (For<T>(IEnumerable<T>)).

    Source

    for_type

    fn for_type() -> OrderedComparerTypeWrapper<T>
    

    The builder of comparers of T (For<T>()). The builder is not a comparer itself: its order_by methods give one.

    Source

    order_by

    fn order_by<V: Ord + 'static>(selector: impl Fn(&T) -> V + 'static) -> Comparer<T>
    

    In ascending order of the values of selector, compared by their Ord (OrderBy<TValue>(Func<T, TValue>)).

    Source

    order_by_with

    fn order_by_with<V: 'static>(selector: impl Fn(&T) -> V + 'static, comparer: Comparer<V>) -> Comparer<T>
    

    In ascending order of the values of selector, compared by comparer (OrderBy<TValue>(Func<T, TValue>, IComparer<TValue>)).

    Source

    order_by_descending

    fn order_by_descending<V: Ord + 'static>(selector: impl Fn(&T) -> V + 'static) -> Comparer<T>
    

    In descending order of the values of selector, compared by their Ord (OrderByDescending<TValue>(Func<T, TValue>)).

    Source

    order_by_descending_with

    fn order_by_descending_with<V: 'static>(selector: impl Fn(&T) -> V + 'static, comparer: Comparer<V>) -> Comparer<T>
    

    In descending order of the values of selector, compared by comparer (OrderByDescending<TValue>(Func<T, TValue>, IComparer<TValue>)).

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.