Re:Rust 1.45
by steveklabnik on Thursday July 16, 2020 @04:12PM
(#23863324)
It is possible, someone needs to do the RFC work.
I would say that my personal take of the temperature is "vaguely pro but not a slam dunk", at least from the opinions I've seen. Only one way to find out.
Then what do you propose for replacement? C++ style casts `(int) x` ?
into()/try_into() and methods designed for each of the other cases (e.g. truncate(), saturating_to_int(), approx_to_float(), etc.)
Using `x.into()` instead or `x.try_into()` if it can fail.
What would you suggest for replacing e.g. `u8 as usize`?
Re:Rust 1.45
by steveklabnik on Friday July 17, 2020 @08:12AM
(#23869657)
For this one, you could use From/Into, because it cannot fail. For numerics that can fail, TryFrom/TryInto.
The numeric casts are the easy part of this.
Something so lossy and ill-conceived should not be a two-letter operator.