-
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Relevant commit: 2b3fcf1
parallel-disk-usage/tests/_utils.rs
Lines 335 to 367 in 2b3fcf1
/// Utility methods to sort various types of arrays. | |
pub trait IntoSorted<Item>: Sized { | |
/// Sort an array by [`Ord`] and return it. | |
fn into_sorted(self) -> Self | |
where | |
Item: Ord; | |
/// Sort an array by a function and return it. | |
fn into_sorted_by<Order>(self, order: Order) -> Self | |
where | |
Order: FnMut(&Item, &Item) -> Ordering; | |
} | |
impl<Item, Array> IntoSorted<Item> for Array | |
where | |
Array: AsMut<[Item]> + Sized, | |
{ | |
fn into_sorted(mut self) -> Self | |
where | |
Item: Ord, | |
{ | |
self.as_mut().sort(); | |
self | |
} | |
fn into_sorted_by<Order>(mut self, order: Order) -> Self | |
where | |
Order: FnMut(&Item, &Item) -> Ordering, | |
{ | |
self.as_mut().sort_by(order); | |
self | |
} | |
} |
Metadata
Metadata
Assignees
Labels
No labels