-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
GuillaumeGomez commentedon Aug 18, 2018
Seems reasonable. Adding it.
Rollup merge of rust-lang#53476 - GuillaumeGomez:try-from-int-error-p…
Rollup merge of rust-lang#53476 - GuillaumeGomez:try-from-int-error-p…
Rollup merge of rust-lang#53476 - GuillaumeGomez:try-from-int-error-p…