I agree that
as should be replaced by more explicit methods. Below are just nits.
For combinations of primitive number types where they are implemented, the general-purpose convert::Into and convert::From traits offer exact conversion: o always represents the exact same real number as i.
Floating-point types are not subsets of the real number +/- Infinity and NaN.
Also, there is -0. Is converting -0f32 to f64 preserve -0? Is it can be 0? Is a bit pattern of NaN preserved?
I::modulo_to<O>(self) -> O method for modulo conversion, also known as bit-truncating conversion.
I find this naming confusing as
modulo_to seems like a binary operation. I propose it
Write that this method is only implemented if and only if the number of bits of
O is less than the number of bits of
I::saturating_to<O>(self) -> O method for saturating conversion.
o is the value arithmetically closest to
O can represent. This is
O::MAX for underflow or overflow respectively.
The condition of the method is the same as above.
"Arithmetically close" is not a usual term and just "close" is enough I think. Also, the term "underflow" has a different meaning when used for floating-point numbers. Alternative terms are "negative overflow" and "positive overflow".
Rounding is according to roundTiesToEven mode as defined in IEEE 754-2008 §4.3.1: pick the nearest floating point number, preferring the one with an even least significant digit if exactly halfway between two floating point numbers.
In my opinion, the rounding mode should be more explicit. I propose to name it
I::round_ties_to_even and preferably provide other rounding modes.