1use crate::num::TryFromIntError;
2
3mod private {
4 #[unstable(feature = "convert_float_to_int", issue = "67057")]
8 pub trait Sealed {}
9}
10
11#[unstable(feature = "convert_float_to_int", issue = "67057")]
14pub trait FloatToInt<Int>: private::Sealed + Sized {
15 #[unstable(feature = "convert_float_to_int", issue = "67057")]
16 #[doc(hidden)]
17 unsafe fn to_int_unchecked(self) -> Int;
18}
19
20macro_rules! impl_float_to_int {
21 ($Float:ty => $($Int:ty),+) => {
22 #[unstable(feature = "convert_float_to_int", issue = "67057")]
23 impl private::Sealed for $Float {}
24 $(
25 #[unstable(feature = "convert_float_to_int", issue = "67057")]
26 impl FloatToInt<$Int> for $Float {
27 #[inline]
28 unsafe fn to_int_unchecked(self) -> $Int {
29 unsafe { crate::intrinsics::float_to_int_unchecked(self) }
31 }
32 }
33 )+
34 }
35}
36
37impl_float_to_int!(f16 => u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
38impl_float_to_int!(f32 => u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
39impl_float_to_int!(f64 => u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
40impl_float_to_int!(f128 => u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
41
42macro_rules! impl_from_bool {
44 ($($int:ty)*) => {$(
45 #[stable(feature = "from_bool", since = "1.28.0")]
46 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
47 impl const From<bool> for $int {
48 #[doc = concat!("[`", stringify!($int), "`]")]
50 #[doc = concat!("assert_eq!(", stringify!($int), "::from(false), 0);")]
56 #[doc = concat!("assert_eq!(", stringify!($int), "::from(true), 1);")]
58 #[inline(always)]
60 fn from(b: bool) -> Self {
61 b as Self
62 }
63 }
64 )*}
65}
66
67impl_from_bool!(u8 u16 u32 u64 u128 usize);
69impl_from_bool!(i8 i16 i32 i64 i128 isize);
70
71macro_rules! impl_from {
73 ($small:ty => $large:ty, #[$attr:meta]) => {
74 #[$attr]
75 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
76 impl const From<$small> for $large {
77 #[doc = concat!("Converts from [`", stringify!($small), "`] to [`", stringify!($large), "`] losslessly.")]
78 #[inline(always)]
79 fn from(small: $small) -> Self {
80 debug_assert!(<$large>::MIN as i128 <= <$small>::MIN as i128);
81 debug_assert!(<$small>::MAX as u128 <= <$large>::MAX as u128);
82 small as Self
83 }
84 }
85 }
86}
87
88impl_from!(u8 => u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
90impl_from!(u8 => u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
91impl_from!(u8 => u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
92impl_from!(u8 => u128, #[stable(feature = "i128", since = "1.26.0")]);
93impl_from!(u8 => usize, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
94impl_from!(u16 => u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
95impl_from!(u16 => u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
96impl_from!(u16 => u128, #[stable(feature = "i128", since = "1.26.0")]);
97impl_from!(u32 => u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
98impl_from!(u32 => u128, #[stable(feature = "i128", since = "1.26.0")]);
99impl_from!(u64 => u128, #[stable(feature = "i128", since = "1.26.0")]);
100
101impl_from!(i8 => i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
103impl_from!(i8 => i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
104impl_from!(i8 => i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
105impl_from!(i8 => i128, #[stable(feature = "i128", since = "1.26.0")]);
106impl_from!(i8 => isize, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
107impl_from!(i16 => i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
108impl_from!(i16 => i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
109impl_from!(i16 => i128, #[stable(feature = "i128", since = "1.26.0")]);
110impl_from!(i32 => i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
111impl_from!(i32 => i128, #[stable(feature = "i128", since = "1.26.0")]);
112impl_from!(i64 => i128, #[stable(feature = "i128", since = "1.26.0")]);
113
114impl_from!(u8 => i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
116impl_from!(u8 => i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
117impl_from!(u8 => i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
118impl_from!(u8 => i128, #[stable(feature = "i128", since = "1.26.0")]);
119impl_from!(u16 => i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
120impl_from!(u16 => i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
121impl_from!(u16 => i128, #[stable(feature = "i128", since = "1.26.0")]);
122impl_from!(u32 => i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
123impl_from!(u32 => i128, #[stable(feature = "i128", since = "1.26.0")]);
124impl_from!(u64 => i128, #[stable(feature = "i128", since = "1.26.0")]);
125
126impl_from!(u16 => usize, #[stable(feature = "lossless_iusize_conv", since = "1.26.0")]);
130impl_from!(u8 => isize, #[stable(feature = "lossless_iusize_conv", since = "1.26.0")]);
131impl_from!(i16 => isize, #[stable(feature = "lossless_iusize_conv", since = "1.26.0")]);
132
133impl_from!(i8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
152impl_from!(i8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
153impl_from!(i8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
154impl_from!(i8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
155impl_from!(i16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
156impl_from!(i16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
157impl_from!(i16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
158impl_from!(i32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
159impl_from!(i32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
160impl_from!(u8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
165impl_from!(u8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
166impl_from!(u8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
167impl_from!(u8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
168impl_from!(u16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
169impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
170impl_from!(u16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
171impl_from!(u32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
172impl_from!(u32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
173impl_from!(f16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
180impl_from!(f16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
181impl_from!(f32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
182impl_from!(f32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
183impl_from!(f64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
184
185macro_rules! impl_float_from_bool {
186 (
187 $float:ty $(;
188 doctest_prefix: $(#[doc = $doctest_prefix:literal])*
189 doctest_suffix: $(#[doc = $doctest_suffix:literal])*
190 )?
191 ) => {
192 #[stable(feature = "float_from_bool", since = "1.68.0")]
193 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
194 impl const From<bool> for $float {
195 #[doc = concat!("Converts a [`bool`] to [`", stringify!($float),"`] losslessly.")]
196 $($(#[doc = $doctest_prefix])*)?
201 #[doc = concat!("let x: ", stringify!($float)," = false.into();")]
202 #[doc = concat!("let y: ", stringify!($float)," = true.into();")]
206 $($(#[doc = $doctest_suffix])*)?
208 #[inline]
210 fn from(small: bool) -> Self {
211 small as u8 as Self
212 }
213 }
214 };
215}
216
217impl_float_from_bool!(
219 f16;
220 doctest_prefix:
221 doctest_suffix:
227 );
229impl_float_from_bool!(f32);
230impl_float_from_bool!(f64);
231impl_float_from_bool!(
232 f128;
233 doctest_prefix:
234 doctest_suffix:
239 );
241
242macro_rules! impl_try_from_unbounded {
244 ($source:ty => $($target:ty),+) => {$(
245 #[stable(feature = "try_from", since = "1.34.0")]
246 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
247 impl const TryFrom<$source> for $target {
248 type Error = TryFromIntError;
249
250 #[inline]
254 fn try_from(value: $source) -> Result<Self, Self::Error> {
255 Ok(value as Self)
256 }
257 }
258 )*}
259}
260
261macro_rules! impl_try_from_lower_bounded {
263 ($source:ty => $($target:ty),+) => {$(
264 #[stable(feature = "try_from", since = "1.34.0")]
265 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
266 impl const TryFrom<$source> for $target {
267 type Error = TryFromIntError;
268
269 #[inline]
273 fn try_from(u: $source) -> Result<Self, Self::Error> {
274 if u >= 0 {
275 Ok(u as Self)
276 } else {
277 Err(TryFromIntError(()))
278 }
279 }
280 }
281 )*}
282}
283
284macro_rules! impl_try_from_upper_bounded {
286 ($source:ty => $($target:ty),+) => {$(
287 #[stable(feature = "try_from", since = "1.34.0")]
288 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
289 impl const TryFrom<$source> for $target {
290 type Error = TryFromIntError;
291
292 #[inline]
296 fn try_from(u: $source) -> Result<Self, Self::Error> {
297 if u > (Self::MAX as $source) {
298 Err(TryFromIntError(()))
299 } else {
300 Ok(u as Self)
301 }
302 }
303 }
304 )*}
305}
306
307macro_rules! impl_try_from_both_bounded {
309 ($source:ty => $($target:ty),+) => {$(
310 #[stable(feature = "try_from", since = "1.34.0")]
311 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
312 impl const TryFrom<$source> for $target {
313 type Error = TryFromIntError;
314
315 #[inline]
319 fn try_from(u: $source) -> Result<Self, Self::Error> {
320 let min = Self::MIN as $source;
321 let max = Self::MAX as $source;
322 if u < min || u > max {
323 Err(TryFromIntError(()))
324 } else {
325 Ok(u as Self)
326 }
327 }
328 }
329 )*}
330}
331
332macro_rules! impl_try_from_integer_for_bool {
334 ($($int:ty)+) => {$(
335 #[stable(feature = "try_from", since = "1.34.0")]
336 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
337 impl const TryFrom<$int> for bool {
338 type Error = TryFromIntError;
339
340 #[doc = concat!("assert_eq!(0_", stringify!($int), ".try_into(), Ok(false));")]
347 #[doc = concat!("assert_eq!(1_", stringify!($int), ".try_into(), Ok(true));")]
349 #[doc = concat!("assert!(<", stringify!($int), " as TryInto<bool>>::try_into(2).is_err());")]
351 #[inline]
353 fn try_from(i: $int) -> Result<Self, Self::Error> {
354 match i {
355 0 => Ok(false),
356 1 => Ok(true),
357 _ => Err(TryFromIntError(())),
358 }
359 }
360 }
361 )*}
362}
363
364macro_rules! rev {
365 ($mac:ident, $source:ty => $($target:ty),+) => {$(
366 $mac!($target => $source);
367 )*}
368}
369
370impl_try_from_integer_for_bool!(u128 u64 u32 u16 u8);
372impl_try_from_integer_for_bool!(i128 i64 i32 i16 i8);
373
374impl_try_from_upper_bounded!(u16 => u8);
376impl_try_from_upper_bounded!(u32 => u8, u16);
377impl_try_from_upper_bounded!(u64 => u8, u16, u32);
378impl_try_from_upper_bounded!(u128 => u8, u16, u32, u64);
379
380impl_try_from_both_bounded!(i16 => i8);
382impl_try_from_both_bounded!(i32 => i8, i16);
383impl_try_from_both_bounded!(i64 => i8, i16, i32);
384impl_try_from_both_bounded!(i128 => i8, i16, i32, i64);
385
386impl_try_from_upper_bounded!(u8 => i8);
388impl_try_from_upper_bounded!(u16 => i8, i16);
389impl_try_from_upper_bounded!(u32 => i8, i16, i32);
390impl_try_from_upper_bounded!(u64 => i8, i16, i32, i64);
391impl_try_from_upper_bounded!(u128 => i8, i16, i32, i64, i128);
392
393impl_try_from_lower_bounded!(i8 => u8, u16, u32, u64, u128);
395impl_try_from_both_bounded!(i16 => u8);
396impl_try_from_lower_bounded!(i16 => u16, u32, u64, u128);
397impl_try_from_both_bounded!(i32 => u8, u16);
398impl_try_from_lower_bounded!(i32 => u32, u64, u128);
399impl_try_from_both_bounded!(i64 => u8, u16, u32);
400impl_try_from_lower_bounded!(i64 => u64, u128);
401impl_try_from_both_bounded!(i128 => u8, u16, u32, u64);
402impl_try_from_lower_bounded!(i128 => u128);
403
404impl_try_from_upper_bounded!(usize => isize);
406impl_try_from_lower_bounded!(isize => usize);
407
408#[cfg(target_pointer_width = "16")]
409mod ptr_try_from_impls {
410 use super::TryFromIntError;
411
412 impl_try_from_upper_bounded!(usize => u8);
413 impl_try_from_unbounded!(usize => u16, u32, u64, u128);
414 impl_try_from_upper_bounded!(usize => i8, i16);
415 impl_try_from_unbounded!(usize => i32, i64, i128);
416
417 impl_try_from_both_bounded!(isize => u8);
418 impl_try_from_lower_bounded!(isize => u16, u32, u64, u128);
419 impl_try_from_both_bounded!(isize => i8);
420 impl_try_from_unbounded!(isize => i16, i32, i64, i128);
421
422 rev!(impl_try_from_upper_bounded, usize => u32, u64, u128);
423 rev!(impl_try_from_lower_bounded, usize => i8, i16);
424 rev!(impl_try_from_both_bounded, usize => i32, i64, i128);
425
426 rev!(impl_try_from_upper_bounded, isize => u16, u32, u64, u128);
427 rev!(impl_try_from_both_bounded, isize => i32, i64, i128);
428}
429
430#[cfg(target_pointer_width = "32")]
431mod ptr_try_from_impls {
432 use super::TryFromIntError;
433
434 impl_try_from_upper_bounded!(usize => u8, u16);
435 impl_try_from_unbounded!(usize => u32, u64, u128);
436 impl_try_from_upper_bounded!(usize => i8, i16, i32);
437 impl_try_from_unbounded!(usize => i64, i128);
438
439 impl_try_from_both_bounded!(isize => u8, u16);
440 impl_try_from_lower_bounded!(isize => u32, u64, u128);
441 impl_try_from_both_bounded!(isize => i8, i16);
442 impl_try_from_unbounded!(isize => i32, i64, i128);
443
444 rev!(impl_try_from_unbounded, usize => u32);
445 rev!(impl_try_from_upper_bounded, usize => u64, u128);
446 rev!(impl_try_from_lower_bounded, usize => i8, i16, i32);
447 rev!(impl_try_from_both_bounded, usize => i64, i128);
448
449 rev!(impl_try_from_unbounded, isize => u16);
450 rev!(impl_try_from_upper_bounded, isize => u32, u64, u128);
451 rev!(impl_try_from_unbounded, isize => i32);
452 rev!(impl_try_from_both_bounded, isize => i64, i128);
453}
454
455#[cfg(target_pointer_width = "64")]
456mod ptr_try_from_impls {
457 use super::TryFromIntError;
458
459 impl_try_from_upper_bounded!(usize => u8, u16, u32);
460 impl_try_from_unbounded!(usize => u64, u128);
461 impl_try_from_upper_bounded!(usize => i8, i16, i32, i64);
462 impl_try_from_unbounded!(usize => i128);
463
464 impl_try_from_both_bounded!(isize => u8, u16, u32);
465 impl_try_from_lower_bounded!(isize => u64, u128);
466 impl_try_from_both_bounded!(isize => i8, i16, i32);
467 impl_try_from_unbounded!(isize => i64, i128);
468
469 rev!(impl_try_from_unbounded, usize => u32, u64);
470 rev!(impl_try_from_upper_bounded, usize => u128);
471 rev!(impl_try_from_lower_bounded, usize => i8, i16, i32, i64);
472 rev!(impl_try_from_both_bounded, usize => i128);
473
474 rev!(impl_try_from_unbounded, isize => u16, u32);
475 rev!(impl_try_from_upper_bounded, isize => u64, u128);
476 rev!(impl_try_from_unbounded, isize => i32, i64);
477 rev!(impl_try_from_both_bounded, isize => i128);
478}
479
480use crate::num::NonZero;
482
483macro_rules! impl_nonzero_int_from_nonzero_int {
484 ($Small:ty => $Large:ty) => {
485 #[stable(feature = "nz_int_conv", since = "1.41.0")]
486 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
487 impl const From<NonZero<$Small>> for NonZero<$Large> {
488 #[doc = concat!("Converts <code>[NonZero]\\<[", stringify!($Small), "]></code> ")]
491 #[doc = concat!("to <code>[NonZero]\\<[", stringify!($Large), "]></code> losslessly.")]
492 #[inline]
493 fn from(small: NonZero<$Small>) -> Self {
494 unsafe { Self::new_unchecked(From::from(small.get())) }
496 }
497 }
498 };
499}
500
501impl_nonzero_int_from_nonzero_int!(u8 => u16);
503impl_nonzero_int_from_nonzero_int!(u8 => u32);
504impl_nonzero_int_from_nonzero_int!(u8 => u64);
505impl_nonzero_int_from_nonzero_int!(u8 => u128);
506impl_nonzero_int_from_nonzero_int!(u8 => usize);
507impl_nonzero_int_from_nonzero_int!(u16 => u32);
508impl_nonzero_int_from_nonzero_int!(u16 => u64);
509impl_nonzero_int_from_nonzero_int!(u16 => u128);
510impl_nonzero_int_from_nonzero_int!(u16 => usize);
511impl_nonzero_int_from_nonzero_int!(u32 => u64);
512impl_nonzero_int_from_nonzero_int!(u32 => u128);
513impl_nonzero_int_from_nonzero_int!(u64 => u128);
514
515impl_nonzero_int_from_nonzero_int!(i8 => i16);
517impl_nonzero_int_from_nonzero_int!(i8 => i32);
518impl_nonzero_int_from_nonzero_int!(i8 => i64);
519impl_nonzero_int_from_nonzero_int!(i8 => i128);
520impl_nonzero_int_from_nonzero_int!(i8 => isize);
521impl_nonzero_int_from_nonzero_int!(i16 => i32);
522impl_nonzero_int_from_nonzero_int!(i16 => i64);
523impl_nonzero_int_from_nonzero_int!(i16 => i128);
524impl_nonzero_int_from_nonzero_int!(i16 => isize);
525impl_nonzero_int_from_nonzero_int!(i32 => i64);
526impl_nonzero_int_from_nonzero_int!(i32 => i128);
527impl_nonzero_int_from_nonzero_int!(i64 => i128);
528
529impl_nonzero_int_from_nonzero_int!(u8 => i16);
531impl_nonzero_int_from_nonzero_int!(u8 => i32);
532impl_nonzero_int_from_nonzero_int!(u8 => i64);
533impl_nonzero_int_from_nonzero_int!(u8 => i128);
534impl_nonzero_int_from_nonzero_int!(u8 => isize);
535impl_nonzero_int_from_nonzero_int!(u16 => i32);
536impl_nonzero_int_from_nonzero_int!(u16 => i64);
537impl_nonzero_int_from_nonzero_int!(u16 => i128);
538impl_nonzero_int_from_nonzero_int!(u32 => i64);
539impl_nonzero_int_from_nonzero_int!(u32 => i128);
540impl_nonzero_int_from_nonzero_int!(u64 => i128);
541
542macro_rules! impl_nonzero_int_try_from_int {
543 ($Int:ty) => {
544 #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")]
545 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
546 impl const TryFrom<$Int> for NonZero<$Int> {
547 type Error = TryFromIntError;
548
549 #[doc = concat!("Attempts to convert [`", stringify!($Int), "`] ")]
552 #[doc = concat!("to <code>[NonZero]\\<[", stringify!($Int), "]></code>.")]
553 #[inline]
554 fn try_from(value: $Int) -> Result<Self, Self::Error> {
555 Self::new(value).ok_or(TryFromIntError(()))
556 }
557 }
558 };
559}
560
561impl_nonzero_int_try_from_int!(u8);
563impl_nonzero_int_try_from_int!(u16);
564impl_nonzero_int_try_from_int!(u32);
565impl_nonzero_int_try_from_int!(u64);
566impl_nonzero_int_try_from_int!(u128);
567impl_nonzero_int_try_from_int!(usize);
568impl_nonzero_int_try_from_int!(i8);
569impl_nonzero_int_try_from_int!(i16);
570impl_nonzero_int_try_from_int!(i32);
571impl_nonzero_int_try_from_int!(i64);
572impl_nonzero_int_try_from_int!(i128);
573impl_nonzero_int_try_from_int!(isize);
574
575macro_rules! impl_nonzero_int_try_from_nonzero_int {
576 ($source:ty => $($target:ty),+) => {$(
577 #[stable(feature = "nzint_try_from_nzint_conv", since = "1.49.0")]
578 #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
579 impl const TryFrom<NonZero<$source>> for NonZero<$target> {
580 type Error = TryFromIntError;
581
582 #[doc = concat!("Attempts to convert <code>[NonZero]\\<[", stringify!($source), "]></code> ")]
585 #[doc = concat!("to <code>[NonZero]\\<[", stringify!($target), "]></code>.")]
586 #[inline]
587 fn try_from(value: NonZero<$source>) -> Result<Self, Self::Error> {
588 Ok(unsafe { Self::new_unchecked(<$target>::try_from(value.get())?) })
590 }
591 }
592 )*};
593}
594
595impl_nonzero_int_try_from_nonzero_int!(u16 => u8);
597impl_nonzero_int_try_from_nonzero_int!(u32 => u8, u16, usize);
598impl_nonzero_int_try_from_nonzero_int!(u64 => u8, u16, u32, usize);
599impl_nonzero_int_try_from_nonzero_int!(u128 => u8, u16, u32, u64, usize);
600impl_nonzero_int_try_from_nonzero_int!(usize => u8, u16, u32, u64, u128);
601
602impl_nonzero_int_try_from_nonzero_int!(i16 => i8);
604impl_nonzero_int_try_from_nonzero_int!(i32 => i8, i16, isize);
605impl_nonzero_int_try_from_nonzero_int!(i64 => i8, i16, i32, isize);
606impl_nonzero_int_try_from_nonzero_int!(i128 => i8, i16, i32, i64, isize);
607impl_nonzero_int_try_from_nonzero_int!(isize => i8, i16, i32, i64, i128);
608
609impl_nonzero_int_try_from_nonzero_int!(u8 => i8);
611impl_nonzero_int_try_from_nonzero_int!(u16 => i8, i16, isize);
612impl_nonzero_int_try_from_nonzero_int!(u32 => i8, i16, i32, isize);
613impl_nonzero_int_try_from_nonzero_int!(u64 => i8, i16, i32, i64, isize);
614impl_nonzero_int_try_from_nonzero_int!(u128 => i8, i16, i32, i64, i128, isize);
615impl_nonzero_int_try_from_nonzero_int!(usize => i8, i16, i32, i64, i128, isize);
616
617impl_nonzero_int_try_from_nonzero_int!(i8 => u8, u16, u32, u64, u128, usize);
619impl_nonzero_int_try_from_nonzero_int!(i16 => u8, u16, u32, u64, u128, usize);
620impl_nonzero_int_try_from_nonzero_int!(i32 => u8, u16, u32, u64, u128, usize);
621impl_nonzero_int_try_from_nonzero_int!(i64 => u8, u16, u32, u64, u128, usize);
622impl_nonzero_int_try_from_nonzero_int!(i128 => u8, u16, u32, u64, u128, usize);
623impl_nonzero_int_try_from_nonzero_int!(isize => u8, u16, u32, u64, u128, usize);