// in rust, generic are more about what you want to do than on what you are // trying to do it, therefore you probably should constraint your generic // on the specific operations you require for your code. If you really need // to constrait on integral types you could use the num crate // but it is likely overkill // example of generic function over additive types: fn example<T1, T2, R>(a:T1, b:T2) -> R where //we only require to be able to add a T2 to a T1 T1: std::ops::Add<T2, Output = R>, { return a + b; }