I'm puzzled by this example. Even though i32
implements all of the Num + One + Zero + PartialOrd + RemAssign + Ord
, when I put them into a trait so I can give an alias, it doesn't work.
use num_traits::{Num, identities::One, identities::Zero};
use std::cmp::{Ord, PartialOrd};
use std::ops::RemAssign;
pub trait Math: Num + One + Zero + PartialOrd + RemAssign + Ord {}
fn s<T: Num + One + Zero + PartialOrd + Ord + RemAssign>(t: T) {
unimplemented!();
}
fn ss<T: Math>(t: T) {
unimplemented!();
}
fn sss() {
let x: i32 = 5;
ss(x);
}
Is there a way to force all the things that implement um + One + Zero + PartialOrd + RemAssign + Ord
to implement Math
?