Created a new math library.
This library will e the math library of the magic game engine. Currently, it defines basic numerical types that can be used in generic programming and a set of generic Vector structures. Tests can be added to the "tests" crate.
This commit is contained in:
29
src/integer.rs
Normal file
29
src/integer.rs
Normal file
@ -0,0 +1,29 @@
|
||||
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);
|
Reference in New Issue
Block a user