Closed Andlon closed 1 year ago
That's a good point.
A larger issue is that Malachite doesn't use TryFrom
at all. TryFrom
didn't exist when I started writing Malachite, so I created my own trait, CheckedFrom
. The main thing stopping me from migrating to TryFrom
is that certain TryFrom
impls are missing, e.g. for converting an f64 to a u32. Malachite does provide that conversion via CheckedFrom
.
In the short term I'll move the Rational-to-f64 conversion to CheckedFrom
and think a bit more about the TryFrom
migration.
Fixed in Malachite 0.3.0. I also replaced CheckedFrom
by TryFrom
everywhere.
The current
From
impls forFrom<f64> for Rational
panics if it encounters a NaN or infinity. It is documented to do so in theimpl
, however it is a violation of theFrom
contract as stipulated by theFrom
trait:So it seems that these impls should rather be
TryFrom
instead.