If you'd like to make sure that your computations don't result in a number that cannot fit into the numeric type you are using, you can always makes some comparison before the computation to the minimum and maximum values of the numeric types.
Here you can see the MIN and MAX values of most of the numeric types of Rust:
examples/min-max-values/src/main.rs
fn main() {
println!("u8::MIN {}", u8::MIN);
println!("u8::MAX {}", u8::MAX);
println!();
println!("i8::MIN {}", i8::MIN);
println!("i8::MAX {}", i8::MAX);
println!();
println!("u16::MIN {}", u16::MIN);
println!("u16::MAX {}", u16::MAX);
println!();
println!("i16::MIN {}", i16::MIN);
println!("i16::MAX {}", i16::MAX);
println!();
println!("u32::MIN {}", u32::MIN);
println!("u32::MAX {}", u32::MAX);
println!();
println!("u64::MIN {}", u64::MIN);
println!("u64::MAX {}", u64::MAX);
println!();
println!("i64::MIN {}", i64::MIN);
println!("i64::MAX {}", i64::MAX);
println!();
println!("u128::MIN {}", u128::MIN);
println!("u128::MAX {}", u128::MAX);
println!();
println!("i128::MIN {}", i128::MIN);
println!("i128::MAX {}", i128::MAX);
println!();
println!("f32::MIN {}", f32::MIN);
println!("f32::MAX {}", f32::MAX);
println!();
println!("f64::MIN {}", f64::MIN);
println!("f64::MAX {}", f64::MAX);
println!();
println!("usize::MIN {}", usize::MIN);
println!("usize::MAX {}", usize::MAX);
println!();
println!("isize::MIN {}", isize::MIN);
println!("isize::MAX {}", isize::MAX);
println!();
}
examples/min-max-values/out.txt
u8::MIN 0
u8::MAX 255
i8::MIN -128
i8::MAX 127
u16::MIN 0
u16::MAX 65535
i16::MIN -32768
i16::MAX 32767
u32::MIN 0
u32::MAX 4294967295
u64::MIN 0
u64::MAX 18446744073709551615
i64::MIN -9223372036854775808
i64::MAX 9223372036854775807
u128::MIN 0
u128::MAX 340282366920938463463374607431768211455
i128::MIN -170141183460469231731687303715884105728
i128::MAX 170141183460469231731687303715884105727
f32::MIN -340282350000000000000000000000000000000
f32::MAX 340282350000000000000000000000000000000
f64::MIN -179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
f64::MAX 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
usize::MIN 0
usize::MAX 18446744073709551615
isize::MIN -9223372036854775808
isize::MAX 9223372036854775807