Skip to content

Commit da4febd

Browse files
Add partialeq implementation for TryFromIntError type
1 parent afd0a2f commit da4febd

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
@@ -4248,7 +4248,7 @@ from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
42484248

42494249
/// The error type returned when a checked integral type conversion fails.
42504250
#[unstable(feature = "try_from", issue = "33417")]
4251-
#[derive(Debug, Copy, Clone)]
4251+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
42524252
pub struct TryFromIntError(());
42534253

42544254
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)