Skip to content

PartialEq for TryFromIntError #53458

@leonardo-m

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

GuillaumeGomez

GuillaumeGomez commented on Aug 18, 2018

@GuillaumeGomez
Member

Seems reasonable. Adding it.

added 3 commits that reference this issue on Aug 29, 2018
dbf633f
9379005
a245d9b
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

      Participants

      @GuillaumeGomez@leonardo-m

      Issue actions

        PartialEq for TryFromIntError · Issue #53458 · rust-lang/rust