|
|
|
|
|
by iopq
3455 days ago
|
|
Rust actually has this, this works: 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! |
|