I am newbye with Rust. I don't know how to cast generic type <T> to primitive type.
There is a tiny example a function sum with generic types:
fn sum<T: std::ops::Add<Output = T>, U>(x:T, y: U) -> T {
// is there any line of code similar to:
// x + y as T
x + y as T
// or check the type
// match type(x) {
// i32 => x + y as i32,
// i64 => x + y as i64,
// f32 => x + y as f32,
// _ => 0
// }
}
fn main() {
let a = 1;
let b = 22.22;
println!("{}", sum(a, b));
let a = 11.11;
let b = 2;
println!("{}", sum(a, b));
}