use super::functions::*;
use core::cmp::Ordering;
pub trait IntoSorted<Item>: crate::sealed::IsArray<Item> {
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;
}
impl<Item, Array> IntoSorted<Item> for Array
where
Array: AsMut<[Item]> + Sized,
{
#[inline]
fn into_sorted(self) -> Self
where
Item: Ord,
{
into_sorted(self)
}
#[inline]
fn into_sorted_by<Order>(self, order: Order) -> Self
where
Order: FnMut(&Item, &Item) -> Ordering,
{
into_sorted_by(self, order)
}
#[inline]
fn into_sorted_by_key<Key, GetKey>(self, get_key: GetKey) -> Self
where
GetKey: FnMut(&Item) -> Key,
Key: Ord,
{
into_sorted_by_key(self, get_key)
}
#[inline]
fn into_sorted_by_cached_key<Key, GetKey>(self, get_key: GetKey) -> Self
where
GetKey: FnMut(&Item) -> Key,
Key: Ord,
{
into_sorted_by_cached_key(self, get_key)
}
}