Trait IntoSorted

Source
pub trait IntoSorted<Item>: IsArray<Item> {
    // Required methods
    fn into_sorted(self) -> Self
       where Item: Ord;
    fn into_sorted_by<Order>(self, order: Order) -> Self
       where Order: FnMut(&Item, &Item) -> Ordering;
    fn into_sorted_by_key<Key, GetKey>(self, get_key: GetKey) -> Self
       where GetKey: FnMut(&Item) -> Key,
             Key: Ord;
    fn into_sorted_by_cached_key<Key, GetKey>(self, get_key: GetKey) -> Self
       where GetKey: FnMut(&Item) -> Key,
             Key: Ord;
}
Expand description

Utility methods to sort various types of arrays with a stable algorithm (requires allocation).

Required Methods§

Source

fn into_sorted(self) -> Self
where Item: Ord,

Sort an array by Ord and return it.

This function calls slice::sort under the hook.

Source

fn into_sorted_by<Order>(self, order: Order) -> Self
where Order: FnMut(&Item, &Item) -> Ordering,

Sort an array by a function and return it.

This function calls slice::sort_by under the hook.

Source

fn into_sorted_by_key<Key, GetKey>(self, get_key: GetKey) -> Self
where GetKey: FnMut(&Item) -> Key, Key: Ord,

Sort an array by a key extraction function and return it.

This function calls slice::sort_by_key under the hook.

Source

fn into_sorted_by_cached_key<Key, GetKey>(self, get_key: GetKey) -> Self
where GetKey: FnMut(&Item) -> Key, Key: Ord,

Sort an array by a key extraction function and return it.

This function calls slice::sort_by_cached_key under the hook.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Item, Array> IntoSorted<Item> for Array
where Array: AsMut<[Item]> + Sized,