numeric_constant_traits 0.1.1

Traits for generic numeric constants
Documentation
  • Coverage
  • 50.25%
    100 out of 199 items documented0 out of 198 items with examples
  • Size
  • Source code size: 16.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 13.74 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PanieriLorenzo

numeric_constant_traits

Traits for generic numeric constants

Like the traits Zero and One from the num crate, but for all natural numbers up to and including 100. Allows doing generic arithmetic without having to do casts.

Without this crate you'd need to do something like:

2u8.into() * 3u8.into() + 4u8.into()

Which is okay, but obfuscates a bit what the intent is.

With this crate you can do something like this:

T::two() * T::three() + T::four()

The traits are implemented for all standard numeric types, as well as a blanket implementation for num::Complex<T>, where T is any of the standar numeric types.