| Crates.io | hexga_number |
| lib.rs | hexga_number |
| version | 0.0.11-beta.3 |
| created_at | 2025-03-28 17:32:31.032485+00 |
| updated_at | 2025-08-12 19:04:21.290566+00 |
| description | Provide basic trait and constant for number, and the macro map_on!. |
| homepage | https://github.com/Thomas-Mewily/hexga |
| repository | https://github.com/Thomas-Mewily/hexga |
| max_upload_size | |
| id | 1609905 |
| size | 23,747 |
Provide basic number functionality, like
Some constant in trait : Zero One Half, MaxValue, MinValue, NaNValue,
Some trait that regroup multiple operation :
Type of operations
BitArithmetic : For every type that support bit based operation (and &, or |, xor ^, not !, shift << / >>...).UnitArithmetic : +, -, 0NumberArithmetic : +, -, *, /, %, 0 - ArithmeticNegative : same as NumberArithmetic + Neg operator,Number : +, -, *, /, %, 0, 1, ==, >=, min val, max val,NumberNegative same as Number + Neg operator,Float and Int related : Floating, Integer, IntegerUnsigned, IntegerSigned
Useful macro : map_on_integer, map_on_integer_unsigned, map_on_integer_signed, map_on_float, map_on_number
/// Define the `0` representation : The absorbing element of the multiplication such that `x * X::ZERO = X::ZERO`
pub trait Zero : Sized
{
/// The absorbing element of the multiplication such that `x * X::ZERO = X::ZERO`
const ZERO : Self;
}
map_on_number!(
($name:ident) =>
{
impl Zero for $name
{
const ZERO : Self = 0 as Self;
}
}
);
// and tada! Zero is now implemented for : (`i8`, `i16`, `i32`, `i64`, `isize`) + (`u8`, `u16`, `u32`, `u64`, `usize`) + (`f32`, `f64`)
Check hexga : https://crates.io/crates/hexga if you are interested in a quick start, it regroup multiple hexga crates.