helper: ordered now takes a fixed sized array of type T
I wanted to abstract ordered to any size instead of just binary tuples - but tuples have a strange issue where you can't be generic about them past like a limit of 12. With this setup, ordered takes ownership of some fixed array, sorts it, then returns it back. modes:pair and modes:single have been refactored to utilise this new form of ordered - it's basically the exact same in these cases.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use std::cmp::{max, min};
|
||||
|
||||
pub fn ordered<T: Ord + Copy>(x: T, y: T) -> (T, T) {
|
||||
(min(x, y), max(x, y))
|
||||
pub fn ordered<T: Ord, const N: usize>(mut xs: [T; N]) -> [T; N] {
|
||||
xs.sort();
|
||||
xs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user