|
1 | 1 | use core::convert::TryFrom;
|
2 |
| -use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8, TryFromIntError}; |
| 2 | +use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8}; |
3 | 3 | use core::option::Option::{self, None, Some};
|
4 | 4 | use std::mem::size_of;
|
5 | 5 |
|
@@ -180,18 +180,18 @@ fn test_nonzero_bitor_assign() {
|
180 | 180 |
|
181 | 181 | #[test]
|
182 | 182 | fn test_nonzero_from_int_on_success() {
|
183 |
| - assert_eq!(NonZeroU8::try_from(5), Ok(NonZeroU8::new(5))); |
184 |
| - assert_eq!(NonZeroU32::try_from(5), Ok(NonZeroU32::new(5))); |
| 183 | + assert_eq!(NonZeroU8::try_from(5), Ok(NonZeroU8::new(5).unwrap())); |
| 184 | + assert_eq!(NonZeroU32::try_from(5), Ok(NonZeroU32::new(5).unwrap())); |
185 | 185 |
|
186 |
| - assert_eq!(NonZeroI8::try_from(-5), Ok(NonZeroI8::new(-5))); |
187 |
| - assert_eq!(NonZeroI32::try_from(-5), Ok(NonZeroI32::new(-5))); |
| 186 | + assert_eq!(NonZeroI8::try_from(-5), Ok(NonZeroI8::new(-5).unwrap())); |
| 187 | + assert_eq!(NonZeroI32::try_from(-5), Ok(NonZeroI32::new(-5).unwrap())); |
188 | 188 | }
|
189 | 189 |
|
190 | 190 | #[test]
|
191 | 191 | fn test_nonzero_from_int_on_err() {
|
192 |
| - assert_eq!(NonZeroU8::try_from(0), Err(TryFromIntError(()))); |
193 |
| - assert_eq!(NonZeroU32::try_from(0), Err(TryFromIntError(()))); |
| 192 | + assert!(NonZeroU8::try_from(0).is_err()); |
| 193 | + assert!(NonZeroU32::try_from(0).is_err()); |
194 | 194 |
|
195 |
| - assert_eq!(NonZeroI8::try_from(0), Err(TryFromIntError(()))); |
196 |
| - assert_eq!(NonZeroI32::try_from(0), Err(TryFromIntError(()))); |
| 195 | + assert!(NonZeroI8::try_from(0).is_err()); |
| 196 | + assert!(NonZeroI32::try_from(0).is_err()); |
197 | 197 | }
|
0 commit comments