Skip to content

Commit a245d9b

Browse files
authored
Rollup merge of rust-lang#53476 - GuillaumeGomez:try-from-int-error-partial-eq, r=KodrAus
Add partialeq implementation for TryFromIntError type Fixes rust-lang#53458.
2 parents ba83270 + da4febd commit a245d9b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/libcore/num/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4323,7 +4323,7 @@ from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
43234323

43244324
/// The error type returned when a checked integral type conversion fails.
43254325
#[unstable(feature = "try_from", issue = "33417")]
4326-
#[derive(Debug, Copy, Clone)]
4326+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
43274327
pub struct TryFromIntError(());
43284328

43294329
impl TryFromIntError {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(try_from)]
12+
#![allow(unused_must_use)]
13+
14+
use std::convert::TryFrom;
15+
use std::num::TryFromIntError;
16+
17+
fn main() {
18+
let x: u32 = 125;
19+
let y: Result<u8, TryFromIntError> = u8::try_from(x);
20+
y == Ok(125);
21+
}

0 commit comments

Comments
 (0)