Closed xfbs closed 10 months ago
Interaction with NaN
would severely hamper the usefulness of a ranged float type.
As to a generic version, I would love that, but it's simply not permitted :shrug:
As to a generic version, I would love that, but it's simply not permitted 🤷
I'll put it on my wishlist, maybe Santa feels like implementing it this year. 😆
Interaction with NaN would severely hamper the usefulness of a ranged float type.
Fair. Maybe it would be good to have similar semantics as ordered_float::NotNan
, but with range constraints? I would guess that if you want to constrain values to be in some range, you also don't want to allow NaN
(if you wanted to, there is always Option
for that). I understand that it might be a pain tho.
For my use-case, I have some code where I want to enforce some value to be in some range [0.0, 360.0)
because it is supposed to represent an angle. I would have loved to use deranged
for that 😢
I'll put it on my wishlist, maybe Santa feels like implementing it this year. 😆
I don't think there's much progress on that specific feature of const generics, so it'll be a while if I had to guess. It's not even fully implemented, let alone stabilized.
Using total ordering is a possibility I suppose. Personally I won't be implementing it any time soon as I'm working on some other items that are more impactful. That's not to say a PR isn't welcome, though.
Closing as not planned. Ultimately this is a proof-of-concept for ranged integers, and it's not clear how floating point values would fit with that.
Quick question: would it be possible to get a float variant of this?
Also: it would be so nice if the compiler allowed
pub struct Ranged<T, const MIN: T, const MAX: T>(T);
.Cheers!