Open
Description
PR #66841 adds this supporting trait for the {f32,f64}::approx_unchecked_to
method (tracking issue: #67058) to the core::convert
and std::convert
modules:
mod private {
pub trait Sealed {}
}
pub trait FloatToInt<Int>: private::Sealed + Sized {
#[doc(hidden)]
unsafe fn approx_unchecked(self) -> Int;
}
// Macro-generated for all combinations of primitive integer
// and primitive floating point types:
impl FloatToInt<$Int> for $Float {…}
The name and location (and usage of the sealed-trait pattern) are chosen to allow later adding additional methods with different conversion semantics between those types, as proposed in https://internals.rust-lang.org/t/pre-rfc-add-explicitly-named-numeric-conversion-apis/11395
Metadata
Metadata
Assignees
Labels
Area: Floating point numbers and arithmeticBlocker: Implemented in the nightly compiler and unstable.Category: An issue tracking the progress of sth. like the implementation of an RFCLibs issues that are tracked on the team's project board.Status: The feature will stay unstable indefinitely.Relevant to the library API team, which will review and decide on the PR/issue.