Skip to content

Should fallible methods on jiff::SignedDuration return their own error types? #439

@BurntSushi

Description

@BurntSushi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeIssues that require a breaking change for resolution.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions