num-to 1.0.0

Number conversions without using as.
Documentation
  • Coverage
  • 1.75%
    1 out of 57 items documented0 out of 56 items with examples
  • Size
  • Source code size: 34.18 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.32 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Quelfth/num-to
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Quelfth

This crate provides traits [To{type}] and [As{type}] providing methods [to_{type}] and [as_{type}] for converting numbers between types without using [as] casts. The rules for these names are as follows. Methods named [as_{type}] will always convert the value losslessly producing an exact result, whereas [to_{type]] are possibly lossy but will always convert to the nearest value of the result type during integer-integer conversions, and for conversions involving floating-point values, the result is the same as that of an [as] cast.

Whenever an [As] trait is implemented, the corresponding [To] trait is also implemented, and has the same behavior.

Existence of [AsUsize] and [AsIsize] for a particular type is target architecture dependent, so usage of these traits is discouraged.

[use num-to::*;] will include only the 14 [As] traits, 14 [To] traits and nothing else.