rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
694 stars 131 forks source link

`AsPrimInt` trait #324

Open benwh1 opened 3 months ago

benwh1 commented 3 months ago

ToPrimitive implements conversions to all primitive numeric types, and provides to_T functions for each T, but AsPrimitive only implements a conversion to a single type, and there is currently no unifying trait that combines them all with as_T functions for each T. This change adds this trait, AsPrimInt, and automatically implements it on types that implement AsPrimitive<T> for all primitive integer types T.