@@ -118,23 +118,23 @@ fn cast_to_int_checks_overflow() {
118118 assert_eq ! ( Some ( normal_f as i64 ) , cast:: <f64 , i64 >( normal_f) ) ;
119119
120120 assert_eq ! (
121- NonZeroIsize :: new ( normal_f as isize ) ,
121+ NonZeroIsize :: from_isize ( normal_f as isize ) ,
122122 cast:: <f64 , NonZeroIsize >( normal_f)
123123 ) ;
124124 assert_eq ! (
125- NonZeroI8 :: new ( normal_f as i8 ) ,
125+ NonZeroI8 :: from_i8 ( normal_f as i8 ) ,
126126 cast:: <f64 , NonZeroI8 >( normal_f)
127127 ) ;
128128 assert_eq ! (
129- NonZeroI16 :: new ( normal_f as i16 ) ,
129+ NonZeroI16 :: from_i16 ( normal_f as i16 ) ,
130130 cast:: <f64 , NonZeroI16 >( normal_f)
131131 ) ;
132132 assert_eq ! (
133- NonZeroI32 :: new ( normal_f as i32 ) ,
133+ NonZeroI32 :: from_i32 ( normal_f as i32 ) ,
134134 cast:: <f64 , NonZeroI32 >( normal_f)
135135 ) ;
136136 assert_eq ! (
137- NonZeroI64 :: new ( normal_f as i64 ) ,
137+ NonZeroI64 :: from_i64 ( normal_f as i64 ) ,
138138 cast:: <f64 , NonZeroI64 >( normal_f)
139139 ) ;
140140
@@ -175,23 +175,23 @@ fn cast_to_unsigned_int_checks_overflow() {
175175 assert_eq ! ( Some ( normal_f as u64 ) , cast:: <f64 , u64 >( normal_f) ) ;
176176
177177 assert_eq ! (
178- NonZeroUsize :: new ( normal_f as usize ) ,
178+ NonZeroUsize :: from_usize ( normal_f as usize ) ,
179179 cast:: <f64 , NonZeroUsize >( normal_f)
180180 ) ;
181181 assert_eq ! (
182- NonZeroU8 :: new ( normal_f as u8 ) ,
182+ NonZeroU8 :: from_u8 ( normal_f as u8 ) ,
183183 cast:: <f64 , NonZeroU8 >( normal_f)
184184 ) ;
185185 assert_eq ! (
186- NonZeroU16 :: new ( normal_f as u16 ) ,
186+ NonZeroU16 :: from_u16 ( normal_f as u16 ) ,
187187 cast:: <f64 , NonZeroU16 >( normal_f)
188188 ) ;
189189 assert_eq ! (
190- NonZeroU32 :: new ( normal_f as u32 ) ,
190+ NonZeroU32 :: from_u32 ( normal_f as u32 ) ,
191191 cast:: <f64 , NonZeroU32 >( normal_f)
192192 ) ;
193193 assert_eq ! (
194- NonZeroU64 :: new ( normal_f as u64 ) ,
194+ NonZeroU64 :: from_u64 ( normal_f as u64 ) ,
195195 cast:: <f64 , NonZeroU64 >( normal_f)
196196 ) ;
197197
@@ -223,11 +223,11 @@ fn cast_to_i128_checks_overflow() {
223223 assert_eq ! ( Some ( normal_f as u128 ) , cast:: <f64 , u128 >( normal_f) ) ;
224224
225225 assert_eq ! (
226- NonZeroI128 :: new ( normal_f as i128 ) ,
226+ NonZeroI128 :: from_i128 ( normal_f as i128 ) ,
227227 cast:: <f64 , NonZeroI128 >( normal_f)
228228 ) ;
229229 assert_eq ! (
230- NonZeroU128 :: new ( normal_f as u128 ) ,
230+ NonZeroU128 :: from_u128 ( normal_f as u128 ) ,
231231 cast:: <f64 , NonZeroU128 >( normal_f)
232232 ) ;
233233
@@ -577,6 +577,9 @@ fn newtype_from_primitive() {
577577 }
578578 check ! ( i8 i16 i32 i64 isize ) ;
579579 check ! ( u8 u16 u32 u64 usize ) ;
580+
581+ check ! ( NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroIsize ) ;
582+ check ! ( NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroUsize ) ;
580583}
581584
582585#[ test]
@@ -615,4 +618,7 @@ fn newtype_to_primitive() {
615618 }
616619 check ! ( i8 i16 i32 i64 isize ) ;
617620 check ! ( u8 u16 u32 u64 usize ) ;
621+
622+ check ! ( NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroIsize ) ;
623+ check ! ( NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroUsize ) ;
618624}
0 commit comments