Skip to content

Thoughts on an orElse/unwrapOrElse equivalent? #23

Description

@abrenneke

I'm liking the lib so far! What are your thoughts on orElse methods? Right now if I want to have errors fallback I do:

const res = fn().chain(
  (x) => Result.ok(x),
  () => otherFn()
);

But that could be made a little more ergonomic if it was something like:

const res = fn().orElse((err) => otherFn());

Or the equivalent unwrap:

const val = fn().unwrapOrElse((err) => otherFn());

I get that it's a balance of keeping the lib small and having things be ergonomic - rust has soo many Result methods 😆

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions