10 ms·
u64 as u32 is defined as wrapping (unfortunately, IMO), so it will never panic, not even in debug mode.
by heinrich5991 4y ago
u64 as u32 is defined as wrapping (unfortunately, IMO), so it will never panic, not even in debug mode.
- tialaramex 4y agoI would prefer that u64 as u32 and similar lossy conversions get deprecated in some future Edition encouraging people write try_into and thus take a moment to decide what happens when it won't fit. But yeah, meanwhile the only difference in Rust is that you did explicitly say you wanted the conversion. EtA: the pointer as usize conversions will presumably get deprecated once Aria's provenance experiment is solidified. So that's a precedent for deprecating something like this where the risk outweighs the convenience.
- swsieber 4y agoIIRC they has been at least one proposal working towards that.