No, because if you explicitly converted to another type, that's what you wanted.
fn main() {
let x = 5i32;
let y: i64 = x.into();
println!("{}", y);
}
this doesn't work: fn main() {
let x = 5i32;
let y: i16 = x.into();
println!("{}", y);
}
you have to write: fn main() {
let x = 5i32;
let y = x as i16;
println!("{}", y);
}
where `as` has the potential of being lossy!The casting function could specify the valid input values, and force the programmer to handle the rest of the cases when the input type is wider.
This is a contradiction, something cannot be both silent and explicit.