You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The 0.2.* series of the num-traits crate includes a Real trait (introduced in 0.1.42) that is nearly identical to Decorum's. Before hitting 0.1.0, Decorum should integrate with these changes and replace it's Real trait with num-traits'.
This will be tricky though. num-traits currently provides a blanket implementation such that T: Float ⇒ T: Real (i.e., impl<T> Real for T where T: Float { ... }). This makes it impossible to write implementations of the Float and Real traits for ConstrainedFloat that are parameterized over the input FloatConstraint type. I'm still not sure how to work around this.
The text was updated successfully, but these errors were encountered:
One straightforward solution is to implement Real directly against the non-parameterized types re-exported by Decorum (NotNan and Finite). Unfortunately, this would mean that Real would not be implicitly implemented based on the FloatConstraint used to construct the type. If a new proxy type were added, it would be easy to forget the corresponding Real implementation, for example.
This would also involve a lot of duplicated code. A macro could help with this, but it's a bit ugly. Since there is no way to address this without a breaking change to num-traits, it will probably be necessary to do something like this.
7d9449a upgrades num-traits to 0.2.* and implements the Real trait from that crate for relevant proxy types via a macro.
There are some small differences between Decorum's Real and num-traits' Real, so that commit does not remove the trait from Decorum. Instead, it simply implements both. That isn't ideal; at the very least, it may be worth advocating for using one over the other in documentation.
This issue is primarily about upgrading to num-traits 0.2.*, so I'll close it. It'll probably be worth considering how to move forward with the Real traits though.
The
0.2.*
series of the num-traits crate includes aReal
trait (introduced in0.1.42
) that is nearly identical to Decorum's. Before hitting0.1.0
, Decorum should integrate with these changes and replace it'sReal
trait with num-traits'.This will be tricky though. num-traits currently provides a blanket implementation such that
T: Float ⇒ T: Real
(i.e.,impl<T> Real for T where T: Float { ... }
). This makes it impossible to write implementations of theFloat
andReal
traits forConstrainedFloat
that are parameterized over the inputFloatConstraint
type. I'm still not sure how to work around this.The text was updated successfully, but these errors were encountered: