Skip to content

Result::and() and Result::and_then() could be generic over FromError implementors #18991

Description

The error interoperation RFC (rust-lang/rfcs#201) did not cover adapting the current APIs such as Result to be more general purpose with regards to the new FromError trait.

It seems to me that the current signatures of and and and_then:

fn and<U>(self, res: Result<U, E>) -> Result<U, E>
fn and_then<U>(self, op: |T| -> Result<U, E>) -> Result<U, E>

could now be:

fn and<U, F: FromError<E>>(self, res: Result<U, F>) -> Result<U, F>
fn and_then<U, F: FromError<E>>(self, op: |T| -> Result<U, F>) -> Result<U, F>

to allow using these combinators in the same cross-boundary fashion as the try! macro.

This would also require a blanket implementation of FromError<E> for any E.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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