@@ -56,6 +56,14 @@ will only require minor version bumps, but will need significant justification.
5656#![ forbid( missing_docs) ]
5757#![ cfg_attr( not( feature = "std" ) , no_std) ]
5858
59+ #[ macro_use]
60+ mod enum_impl;
61+
62+ #[ cfg( feature = "enum_repr_16" ) ]
63+ use enum_impl:: i16_repr:: I16Repr ;
64+ use enum_impl:: i8_repr:: I8Repr ;
65+ use enum_impl:: u8_repr:: U8Repr ;
66+
5967/// An error type returned when a checked integral type conversion fails (mimics [std::num::TryFromIntError])
6068#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
6169pub struct TryFromIntError ( ( ) ) ;
@@ -401,14 +409,25 @@ macro_rules! nonmax_impls {
401409 } ;
402410}
403411
404- nonmax_impls ! ( def, signed, NonMaxI8 , NonZeroI8 , i8 ) ;
412+ enum_impl:: nonmax!( NonMaxI8 , i8 , I8Repr ) ;
413+ enum_impl:: nonmax!( NonMaxU8 , u8 , U8Repr ) ;
414+ #[ cfg( feature = "enum_repr_16" ) ]
415+ enum_impl:: nonmax!( NonMaxI16 , i16 , I16Repr ) ;
416+
417+ nonmax_impls ! ( signed, NonMaxI8 , NonZeroI8 , i8 ) ;
418+ #[ cfg( feature = "enum_repr_16" ) ]
419+ nonmax_impls ! ( signed, NonMaxI16 , NonZeroI16 , i16 ) ;
420+ #[ cfg( not( feature = "enum_repr_16" ) ) ]
405421nonmax_impls ! ( def, signed, NonMaxI16 , NonZeroI16 , i16 ) ;
406422nonmax_impls ! ( def, signed, NonMaxI32 , NonZeroI32 , i32 ) ;
407423nonmax_impls ! ( def, signed, NonMaxI64 , NonZeroI64 , i64 ) ;
408424nonmax_impls ! ( def, signed, NonMaxI128 , NonZeroI128 , i128 ) ;
409425nonmax_impls ! ( def, signed, NonMaxIsize , NonZeroIsize , isize ) ;
410426
411- nonmax_impls ! ( def, unsigned, NonMaxU8 , NonZeroU8 , u8 ) ;
427+ nonmax_impls ! ( unsigned, NonMaxU8 , NonZeroU8 , u8 ) ;
428+ #[ cfg( feature = "enum_repr_16" ) ]
429+ nonmax_impls ! ( unsigned, NonMaxU16 , NonZeroU16 , u16 ) ;
430+ #[ cfg( not( feature = "enum_repr_16" ) ) ]
412431nonmax_impls ! ( def, unsigned, NonMaxU16 , NonZeroU16 , u16 ) ;
413432nonmax_impls ! ( def, unsigned, NonMaxU32 , NonZeroU32 , u32 ) ;
414433nonmax_impls ! ( def, unsigned, NonMaxU64 , NonZeroU64 , u64 ) ;
0 commit comments