Hi, have the maintainers of the standard library considered adding wrapper structs for f32
/f64
that ensure the values are not nan
, +inf
, or -inf
? Finite floats are implemented by a number of crates, but adding them to the standard library would allow Option<FiniteF32>
and Option<FiniteF64>
to occupy just 4 bytes and 8 bytes respectively, by using nan
, +inf
, or -inf
as the None
value. This is similar to how std::num::NonZero*
use rustc_layout_scalar_valid_range_start
to use 0
as the None
value. Thanks!
5 Likes
Perhaps (Pre-?)Pre-RFC: Range-restricting wrappers for floating-point types is the closest to relevant. Searching for NonNan
in particular gets a few more.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.