into_sorted/stable/
methods.rs1use super::functions::*;
2use core::cmp::Ordering;
3
4pub trait IntoSorted<Item>: crate::sealed::IsArray<Item> {
6 fn into_sorted(self) -> Self
8 where
9 Item: Ord;
10
11 fn into_sorted_by<Order>(self, order: Order) -> Self
13 where
14 Order: FnMut(&Item, &Item) -> Ordering;
15
16 fn into_sorted_by_key<Key, GetKey>(self, get_key: GetKey) -> Self
18 where
19 GetKey: FnMut(&Item) -> Key,
20 Key: Ord;
21
22 fn into_sorted_by_cached_key<Key, GetKey>(self, get_key: GetKey) -> Self
24 where
25 GetKey: FnMut(&Item) -> Key,
26 Key: Ord;
27}
28
29impl<Item, Array> IntoSorted<Item> for Array
30where
31 Array: AsMut<[Item]> + Sized,
32{
33 #[inline]
34 fn into_sorted(self) -> Self
35 where
36 Item: Ord,
37 {
38 into_sorted(self)
39 }
40
41 #[inline]
42 fn into_sorted_by<Order>(self, order: Order) -> Self
43 where
44 Order: FnMut(&Item, &Item) -> Ordering,
45 {
46 into_sorted_by(self, order)
47 }
48
49 #[inline]
50 fn into_sorted_by_key<Key, GetKey>(self, get_key: GetKey) -> Self
51 where
52 GetKey: FnMut(&Item) -> Key,
53 Key: Ord,
54 {
55 into_sorted_by_key(self, get_key)
56 }
57
58 #[inline]
59 fn into_sorted_by_cached_key<Key, GetKey>(self, get_key: GetKey) -> Self
60 where
61 GetKey: FnMut(&Item) -> Key,
62 Key: Ord,
63 {
64 into_sorted_by_cached_key(self, get_key)
65 }
66}