File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change
1
+ //! This test verifies that `std::num::TryFromIntError` correctly implements `PartialEq`,
2
+ //! allowing `Result<T, TryFromIntError>` values to be compared for equality using `==`.
3
+ //! It specifically checks a successful numeric conversion scenario where the `Result::Ok`
4
+ //! variant is compared, ensuring that the comparison yields the expected boolean result.
5
+
1
6
//@ run-pass
2
7
3
- #![ allow( unused_must_use) ]
8
+ #![ allow( unused_must_use) ] // Allow ignoring the result of the comparison for the test's purpose
4
9
5
10
use std:: convert:: TryFrom ;
6
11
use std:: num:: TryFromIntError ;
7
12
8
13
fn main ( ) {
9
14
let x: u32 = 125 ;
15
+ // Attempt to convert u32 to u8, which should succeed as 125 fits in u8.
10
16
let y: Result < u8 , TryFromIntError > = u8:: try_from ( x) ;
17
+ // Verify that the Result can be correctly compared with an Ok value.
11
18
y == Ok ( 125 ) ;
12
19
}
You can’t perform that action at this time.
0 commit comments