rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
731 stars 135 forks source link

`AsPrimInt` trait #324

Open benwh1 opened 6 months ago

benwh1 commented 6 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.