sigils/src/integer.rs

30 lines
691 B
Rust
Raw Normal View History

use super::number::Number;
/// A trait that defines what is required to be considered
/// an Integer. [List of types of numbers][1]
///
/// [1]: https://en.wikipedia.org/wiki/List_of_types_of_numbers
pub trait Integer : Number
{
}
// Create a macro to ease typing and reading.
/// A macro to make implementing the trait easier for all the
/// base integer types in rust.
macro_rules! integer_trait_impl
{
($traitName: ident for $($varType: ty)*) =>
($(
impl $traitName for $varType
{
}
)*)
}
// Implement the trait for the types that are Integers.
integer_trait_impl!(Integer for u8 u16 u32 u64 usize);
integer_trait_impl!(Integer for i8 i16 i32 i64 isize);