Is there a nicer way of doing arithmetics on different primitive types (with auto-promotion up) than explicit casting and unwrapping?
For example in case like:
let a: u8 = 1;
let b: u16 = 2;
let c: u32 = 3;
can I somehow get rid of all the casts in:
let total: u64 = a.to_u64().unwrap() + b.to_u64().unwrap() + c.to_u64().unwrap();
Yes, you can use
as
:More info on type casting: http://doc.rust-lang.org/reference.html#type-cast-expressions