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+
16//@ run-pass
27
3- #![ allow( unused_must_use) ]
8+ #![ allow( unused_must_use) ] // Allow ignoring the result of the comparison for the test's purpose
49
510use std:: convert:: TryFrom ;
611use std:: num:: TryFromIntError ;
712
813fn main ( ) {
914 let x: u32 = 125 ;
15+ // Attempt to convert u32 to u8, which should succeed as 125 fits in u8.
1016 let y: Result < u8 , TryFromIntError > = u8:: try_from ( x) ;
17+ // Verify that the Result can be correctly compared with an Ok value.
1118 y == Ok ( 125 ) ;
1219}
You can’t perform that action at this time.
0 commit comments