Number As
Use the trait NumberAs
in the current scope to let all primitive number types have a number_as
method.
use NumberAs;
let a: i32 = 2u16.number_as;
assert_eq!;
assert_eq!;
assert_eq!;
All implements for the NumberAs
trait can be considered as a whole Primitive Number. If you want to design an add function, which accepts all kinds of primitive numbers,
you can use the Number
trait as a trait bound.
use ;
assert_eq!;
Crates.io
https://crates.io/crates/number-as