pub fn constrain<T: Ord>(x: T, a: T, b: T) -> T