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:
2026-04-03 23:56:22 +01:00
committed by oreodave
parent f8f5c12316
commit 892c112433
2 changed files with 5 additions and 6 deletions

View File

@@ -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
}