1pub unsafe trait Integer: num_traits::PrimInt + crate::scalar::Scalar {
9 const WIDTH: usize;
11 const SIGNED: bool;
13}
14
15pub trait SignedInteger: Integer {}
17pub trait UnsignedInteger: Integer {}
19
20macro_rules! impl_numbers {
21 (impl UnsignedInteger for $typ:ty;) => {
22 unsafe impl Integer for $typ {
23 const WIDTH: usize = core::mem::size_of::<$typ>() * 8;
24 const SIGNED: bool = false;
25 }
26
27 impl UnsignedInteger for $typ {}
28 };
29 (impl SignedInteger for $typ:ty;) => {
30 unsafe impl Integer for $typ {
31 const WIDTH: usize = core::mem::size_of::<$typ>() * 8;
32 const SIGNED: bool = true;
33 }
34
35 impl SignedInteger for $typ {}
36 };
37 ($(impl $trait:ident for $typ:ty;)+) => {
38 $(impl_numbers!(impl $trait for $typ;);)+
39 };
40
41}
42
43impl_numbers! {
44 impl UnsignedInteger for u8;
45 impl UnsignedInteger for u16;
46 impl UnsignedInteger for u32;
47 impl UnsignedInteger for u64;
48 impl SignedInteger for i8;
49 impl SignedInteger for i16;
50 impl SignedInteger for i32;
51 impl SignedInteger for i64;
52}