@@ -56,6 +56,16 @@ 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+ #[ cfg( feature = "enum_repr_16" ) ]
65+ use enum_impl:: u16_repr:: U16Repr ;
66+ use enum_impl:: i8_repr:: I8Repr ;
67+ use enum_impl:: u8_repr:: U8Repr ;
68+
5969/// An error type returned when a checked integral type conversion fails (mimics [std::num::TryFromIntError])
6070#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
6171pub struct TryFromIntError ( ( ) ) ;
@@ -401,14 +411,27 @@ macro_rules! nonmax_impls {
401411 } ;
402412}
403413
404- nonmax_impls ! ( def, signed, NonMaxI8 , NonZeroI8 , i8 ) ;
414+ enum_impl:: nonmax!( NonMaxI8 , i8 , I8Repr ) ;
415+ enum_impl:: nonmax!( NonMaxU8 , u8 , U8Repr ) ;
416+ #[ cfg( feature = "enum_repr_16" ) ]
417+ enum_impl:: nonmax!( NonMaxI16 , i16 , I16Repr ) ;
418+ #[ cfg( feature = "enum_repr_16" ) ]
419+ enum_impl:: nonmax!( NonMaxU16 , u16 , U16Repr ) ;
420+
421+ nonmax_impls ! ( signed, NonMaxI8 , NonZeroI8 , i8 ) ;
422+ #[ cfg( feature = "enum_repr_16" ) ]
423+ nonmax_impls ! ( signed, NonMaxI16 , NonZeroI16 , i16 ) ;
424+ #[ cfg( not( feature = "enum_repr_16" ) ) ]
405425nonmax_impls ! ( def, signed, NonMaxI16 , NonZeroI16 , i16 ) ;
406426nonmax_impls ! ( def, signed, NonMaxI32 , NonZeroI32 , i32 ) ;
407427nonmax_impls ! ( def, signed, NonMaxI64 , NonZeroI64 , i64 ) ;
408428nonmax_impls ! ( def, signed, NonMaxI128 , NonZeroI128 , i128 ) ;
409429nonmax_impls ! ( def, signed, NonMaxIsize , NonZeroIsize , isize ) ;
410430
411- nonmax_impls ! ( def, unsigned, NonMaxU8 , NonZeroU8 , u8 ) ;
431+ nonmax_impls ! ( unsigned, NonMaxU8 , NonZeroU8 , u8 ) ;
432+ #[ cfg( feature = "enum_repr_16" ) ]
433+ nonmax_impls ! ( unsigned, NonMaxU16 , NonZeroU16 , u16 ) ;
434+ #[ cfg( not( feature = "enum_repr_16" ) ) ]
412435nonmax_impls ! ( def, unsigned, NonMaxU16 , NonZeroU16 , u16 ) ;
413436nonmax_impls ! ( def, unsigned, NonMaxU32 , NonZeroU32 , u32 ) ;
414437nonmax_impls ! ( def, unsigned, NonMaxU64 , NonZeroU64 , u64 ) ;
0 commit comments