Reputation: 701
How should I cast primitive types in Rust?
In C-derived languages, one normally does
int i = 0;
long j = (long)i;
This does not work in Rust. What should I use instead?
Upvotes: 0
Views: 257
Reputation: 13081
You're looking for the as
keyword:
let x: i32 = 5;
let y: u32 = x as u32;
Upvotes: 6