|
1 |
| -use core::num::{IntErrorKind, NonZeroU8, NonZeroU32, NonZeroI32, ParseIntError}; |
2 |
| -use core::option::Option::{self, Some, None}; |
| 1 | +use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8}; |
| 2 | +use core::option::Option::{self, None, Some}; |
3 | 3 | use std::mem::size_of;
|
4 | 4 |
|
5 | 5 | #[test]
|
@@ -130,21 +130,19 @@ fn test_from_signed_nonzero() {
|
130 | 130 | fn test_from_str() {
|
131 | 131 | assert_eq!("123".parse::<NonZeroU8>(), Ok(NonZeroU8::new(123).unwrap()));
|
132 | 132 | assert_eq!(
|
133 |
| - "0".parse::<NonZeroU8>(), |
134 |
| - Err(ParseIntError { |
135 |
| - kind: IntErrorKind::Zero |
136 |
| - }) |
| 133 | + "0".parse::<NonZeroU8>().err().map(|e| e.kind().clone()), |
| 134 | + Some(IntErrorKind::Zero) |
137 | 135 | );
|
138 | 136 | assert_eq!(
|
139 |
| - "-1".parse::<NonZeroU8>(), |
140 |
| - Err(ParseIntError { |
141 |
| - kind: IntErrorKind::Underflow |
142 |
| - }) |
| 137 | + "-1".parse::<NonZeroU8>().err().map(|e| e.kind().clone()), |
| 138 | + Some(IntErrorKind::InvalidDigit) |
143 | 139 | );
|
144 | 140 | assert_eq!(
|
145 |
| - "257".parse::<NonZeroU8>(), |
146 |
| - Err(ParseIntError { |
147 |
| - kind: IntErrorKind::Overflow |
148 |
| - }) |
| 141 | + "-129".parse::<NonZeroI8>().err().map(|e| e.kind().clone()), |
| 142 | + Some(IntErrorKind::Underflow) |
| 143 | + ); |
| 144 | + assert_eq!( |
| 145 | + "257".parse::<NonZeroU8>().err().map(|e| e.kind().clone()), |
| 146 | + Some(IntErrorKind::Overflow) |
149 | 147 | );
|
150 | 148 | }
|
0 commit comments