newnum
This crate is deprecated. Use num or num-primitive instead.
newnum was an attempt to create well-structured number traits. It defines many
small traits like Round and MinMax to cover common number operations.
One problem with this approach is that many function names mean different things
depending on the type. For example, integer signum returns 0 for 0, but
floating-point signum returns +-1.0 for +-0.0. It is hard to write generic
math code when semantics are not defined.
Usually when writing generic math code you already know what semantics you want. In that case, the easiest solution is to define a custom trait specifically designed for your situation.
See num-primitive for traits implemented strictly for primitives. See
num for non-deprecated general purpose number traits.
Original documentation
The newnum Rust crate is an alternative to the num crate that splits the Rust number API and hierarchy into traits, with a cleaner design than num.
The design of this crate follows these rules:
-
the
Numtrait isn't restricted to primitives, or to types that can represent specific common values (0, 1...). -
the
Prim,SignedPrim,UnsignedPrim,Int,UInt,SInt, andFloattraits are restricted to primitives, but allow nonstdtypes to implement them as long as they follow primitive restrictions. -
API traits (
Round,Root,Trig...) aren't restricted toNumand are designed for non number support, for example<Angle as Trig>::Output = Ratio.