The only such methods currently are SignedDuration::try_from_secs_f64 and its 32-bit counter-part. Currently, these return the god jiff::Error type. But in std, the corresponding methods return a specific TryFromFloatSecsError.
I think I chose the jiff::Error because it avoided defining a new error type and these methods seemed a little niche to me.
But I do somewhat expect that std::time::Duration will eventually get other fallible constructors, and they're either going to return an Option or a Result with their own specific error. So it might be good to decide on this for Jiff 1.0. I suppose the conservative route is to return a new and specific error type. But this does add API noise.
The only such methods currently are
SignedDuration::try_from_secs_f64and its 32-bit counter-part. Currently, these return the godjiff::Errortype. But instd, the corresponding methods return a specificTryFromFloatSecsError.I think I chose the
jiff::Errorbecause it avoided defining a new error type and these methods seemed a little niche to me.But I do somewhat expect that
std::time::Durationwill eventually get other fallible constructors, and they're either going to return anOptionor aResultwith their own specific error. So it might be good to decide on this for Jiff 1.0. I suppose the conservative route is to return a new and specific error type. But this does add API noise.