Skip to content

Add implicit conversion to Result<TValue, TError> #9

Closed

Description

@vix127

Proposal

Add implicit conversion operators allowing a plain TValue to be converted into Result<TValue, TError>.Likewise allow TError to be implicitly converted into Result<TValue, TError> as an Err variant.

Motivation

  • Improve ergonomics: callers can return values/errors directly without wrapping them in Result constructors.
  • Reduce boilerplate in functions that frequently return Result.

Examples

Before:
return new Result(value);
return new Result(error);

After:
return value; // converts to new(value)
return error; // converts to new(error)

Labels: enhancement, proposal

Activity

  1. self-assigned this
    on Aug 13, 2026
  2. added this to the v1.0.0 milestone on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions