Expand description
fundamental types
This crate provides trait unification of the Rust fundamental items, allowing users to declare the behavior they want from a number without committing to a single particular numeric type.
The number types can be categorized along two axes: behavior and width. Traits for each axis and group on that axis are provided:
Numeric Categories
The most general category is represented by the trait Numeric. It is
implemented by all the numeric fundamentals, and includes only the traits that
they all implement. This is an already-large amount: basic memory management,
comparison, rendering, and numeric arithmetic.
The numbers are then split into Floating and Integral. The former fills
out the API of f32 and f64, while the latter covers all of the iN and uN
numbers.
Lastly, Integral splits further, into Signed and Unsigned. These
provide the last specializations unique to the differences between iN and
uN.
Width Categories
Every number implements the trait IsN for the N of its bit width. isize
and usize implement the trait that matches their width on the target platform.
In addition, the trait groups AtLeastN and AtMostN enable clamping the range
of acceptable widths to lower or upper bounds. These traits are equivalent to
mem::size_of::<T>() >= N and mem::size_of::<T>() <= N, respectively.
!