Skip to content

Add function to discard error from result and return optional #98

@jbencin

Description

@jbencin

It would be nice to have the equivalent of Rust's Result::ok(), which discards the error from a Result and return an Option

Currently, to do this you would have to write:

(match (some-parsing-function bytes)
   ok (some ok)
   err none)

Consistent with the syntax I've proposed here for other type conversion functions, I propose adding to-optional to convert result types into optional types:

(to-optional (some-parsing-function bytes))

Metadata

Metadata

Assignees

No one assigned

    Labels

    MMedium sized task; 1 to 5 days in scopenew-builtinThe issue describes a new Clarity builtin (function or variable)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions