num-t
Num<T>: Associate arbitrary types with numeric types
This crate provides the Num<Number, Type> struct, which allows you to associate an arbitrary type Type with a numeric value Number. This can be useful for creating strongly-typed numeric values, preventing mixing of different units or concepts in calculations.
Num<Number, Type> wraps a numeric type Number and uses a std::marker::PhantomData<Type> to carry the type information without adding runtime overhead.
It implements many standard traits, including:
Clone,Copy,DefaultFrom<Scalar>PartialOrd,PartialEq,Eq- Arithmetic operators (
Add,Sub,Mul,Div,Rem,AddAssign, etc.) FromStr,DisplaySum- Traits from the
num-traitscrate:ToPrimitive,NumCast,Num,One,Zero,Float,Bounded,Signed,FromPrimitive.
Optional Features
float_next_after: Implementsfloat_next_after::NextAfterforNumwhen the underlyingNumbertype also implements it.geo: Implementsgeo::GeoNumforNumwhen the underlyingNumbertype also implements it.
License
This crate is licensed under either of
- Apache License, Version 2.0
- MIT license
at your option.