core: implement float conversion methods - #159954
Conversation
This comment has been minimized.
This comment has been minimized.
|
The Codegen Cranelift failure was a pre-existing cg_clif bug in f128 as {i8,i16,u8,u16}, unrelated to this PR. |
1706b22 to
95876c9
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
Seems still failed, is it synced yet or any other issues happen? |
Not synced yet. The fix is rust-lang/rustc_codegen_cranelift@29b9205 and the last subtree sync was #159712. |
|
Alright, cc @bjorn3 for awareness |
Implements the accepted ACP rust-lang/libs-team#810, adding float conversion methods on
f16,f32,f64, andf128:castconverts to the target float type (self as Flt, IEEE rounding).to_int_saturatingconverts to an integer withassemantics: saturating, andNaNto 0.to_int_checkedtruncates toward zero and returnsNoneonNaN, infinity, or out of range.to_int_strictisto_int_checked().unwrap().Per the libs-api meetings on the ACP,
to_floatis namedcastandto_int_saturatingmapsNaNto 0 rather than panicking (which the team noted makes rust-lang/libs-team#831 redundant).The integer-to-float
castfrom the ACP is left out: it shares thecastmethod name on integer types with the integer-to-integercastin rust-lang/libs-team#811 (being unified with the other integer cast methods in rust-lang/libs-team#833), so it needs a decision on how those fit together. Happy to follow up once that settles.Tracking issue: #159913
r? libs