Skip to content

PartialEq for TryFromIntError #53458

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
leonardo-m opened this issue Aug 17, 2018 · 1 comment
Closed

PartialEq for TryFromIntError #53458

leonardo-m opened this issue Aug 17, 2018 · 1 comment
Assignees

Comments

@leonardo-m
Copy link

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.

@GuillaumeGomez
Copy link
Member

Seems reasonable. Adding it.

@GuillaumeGomez GuillaumeGomez self-assigned this Aug 18, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this issue Aug 29, 2018
…artial-eq, r=KodrAus

Add partialeq implementation for TryFromIntError type

Fixes rust-lang#53458.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Aug 29, 2018
…artial-eq, r=KodrAus

Add partialeq implementation for TryFromIntError type

Fixes rust-lang#53458.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Aug 30, 2018
…artial-eq, r=KodrAus

Add partialeq implementation for TryFromIntError type

Fixes rust-lang#53458.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants