Skip to content

PartialEq for TryFromIntError #53458

Description

@leonardo-m

Regarding code like this:

#![feature(try_from, never_type)]
use std::convert::TryFrom;
use std::num::TryFromIntError;

fn main() {
    let x: u8 = 125;
    let y: Result<u32, !> = u32::try_from(x);
    let _ = y == Ok(125); // OK

    let x: u32 = 125;
    let y: Result<u8, TryFromIntError> = u8::try_from(x);
    let _ = y.ok() == Some(125); // OK

    let x: u32 = 125;
    let y: Result<u8, TryFromIntError> = u8::try_from(x);
    let _ = y == Ok(125); // Error
}

I think I'd like the std library to add #[derive(PartialEq)] to std::num::TryFromIntError, so the last line compiles.

Activity

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

Metadata

Metadata

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