@@ -118,23 +118,23 @@ fn cast_to_int_checks_overflow() {
118
118
assert_eq ! ( Some ( normal_f as i64 ) , cast:: <f64 , i64 >( normal_f) ) ;
119
119
120
120
assert_eq ! (
121
- NonZeroIsize :: new ( normal_f as isize ) ,
121
+ NonZeroIsize :: from_isize ( normal_f as isize ) ,
122
122
cast:: <f64 , NonZeroIsize >( normal_f)
123
123
) ;
124
124
assert_eq ! (
125
- NonZeroI8 :: new ( normal_f as i8 ) ,
125
+ NonZeroI8 :: from_i8 ( normal_f as i8 ) ,
126
126
cast:: <f64 , NonZeroI8 >( normal_f)
127
127
) ;
128
128
assert_eq ! (
129
- NonZeroI16 :: new ( normal_f as i16 ) ,
129
+ NonZeroI16 :: from_i16 ( normal_f as i16 ) ,
130
130
cast:: <f64 , NonZeroI16 >( normal_f)
131
131
) ;
132
132
assert_eq ! (
133
- NonZeroI32 :: new ( normal_f as i32 ) ,
133
+ NonZeroI32 :: from_i32 ( normal_f as i32 ) ,
134
134
cast:: <f64 , NonZeroI32 >( normal_f)
135
135
) ;
136
136
assert_eq ! (
137
- NonZeroI64 :: new ( normal_f as i64 ) ,
137
+ NonZeroI64 :: from_i64 ( normal_f as i64 ) ,
138
138
cast:: <f64 , NonZeroI64 >( normal_f)
139
139
) ;
140
140
@@ -175,23 +175,23 @@ fn cast_to_unsigned_int_checks_overflow() {
175
175
assert_eq ! ( Some ( normal_f as u64 ) , cast:: <f64 , u64 >( normal_f) ) ;
176
176
177
177
assert_eq ! (
178
- NonZeroUsize :: new ( normal_f as usize ) ,
178
+ NonZeroUsize :: from_usize ( normal_f as usize ) ,
179
179
cast:: <f64 , NonZeroUsize >( normal_f)
180
180
) ;
181
181
assert_eq ! (
182
- NonZeroU8 :: new ( normal_f as u8 ) ,
182
+ NonZeroU8 :: from_u8 ( normal_f as u8 ) ,
183
183
cast:: <f64 , NonZeroU8 >( normal_f)
184
184
) ;
185
185
assert_eq ! (
186
- NonZeroU16 :: new ( normal_f as u16 ) ,
186
+ NonZeroU16 :: from_u16 ( normal_f as u16 ) ,
187
187
cast:: <f64 , NonZeroU16 >( normal_f)
188
188
) ;
189
189
assert_eq ! (
190
- NonZeroU32 :: new ( normal_f as u32 ) ,
190
+ NonZeroU32 :: from_u32 ( normal_f as u32 ) ,
191
191
cast:: <f64 , NonZeroU32 >( normal_f)
192
192
) ;
193
193
assert_eq ! (
194
- NonZeroU64 :: new ( normal_f as u64 ) ,
194
+ NonZeroU64 :: from_u64 ( normal_f as u64 ) ,
195
195
cast:: <f64 , NonZeroU64 >( normal_f)
196
196
) ;
197
197
@@ -223,11 +223,11 @@ fn cast_to_i128_checks_overflow() {
223
223
assert_eq ! ( Some ( normal_f as u128 ) , cast:: <f64 , u128 >( normal_f) ) ;
224
224
225
225
assert_eq ! (
226
- NonZeroI128 :: new ( normal_f as i128 ) ,
226
+ NonZeroI128 :: from_i128 ( normal_f as i128 ) ,
227
227
cast:: <f64 , NonZeroI128 >( normal_f)
228
228
) ;
229
229
assert_eq ! (
230
- NonZeroU128 :: new ( normal_f as u128 ) ,
230
+ NonZeroU128 :: from_u128 ( normal_f as u128 ) ,
231
231
cast:: <f64 , NonZeroU128 >( normal_f)
232
232
) ;
233
233
@@ -577,6 +577,9 @@ fn newtype_from_primitive() {
577
577
}
578
578
check ! ( i8 i16 i32 i64 isize ) ;
579
579
check ! ( u8 u16 u32 u64 usize ) ;
580
+
581
+ check ! ( NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroIsize ) ;
582
+ check ! ( NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroUsize ) ;
580
583
}
581
584
582
585
#[ test]
@@ -615,4 +618,7 @@ fn newtype_to_primitive() {
615
618
}
616
619
check ! ( i8 i16 i32 i64 isize ) ;
617
620
check ! ( u8 u16 u32 u64 usize ) ;
621
+
622
+ check ! ( NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroIsize ) ;
623
+ check ! ( NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroUsize ) ;
618
624
}
0 commit comments