docs.rs failed to build nonzero_ext-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
nonzero_ext-0.3.0
nonzero_ext
Traits to represent generic nonzero integer types
Rust ships with non-zero integer types now, which let programmers promise (memory-savingly!) that a number can never be zero. That's great, but sadly the standard library has no traits you can use to represent all the non-zero integer types.
Examples
Where this lack of traits in the standard library becomes problematic is if you want to write a function that takes a vector of integers, and that returns a vector of the corresponding non-zero integer types, minus any elements that were zero in the original. You can write that with the standard library quite easily for concrete types:
## use NonZeroU8;
let expected: = vec!;
assert_eq!;
But what if you want to allow this function to work with any integer type that has a corresponding non-zero type? This crate can help:
// It works for `u8`:
let input_u8: = vec!;
let expected_u8: = vec!;
assert_eq!;
// And it works for `u32`:
let input_u32: = vec!;
let expected_u32: = vec!;
assert_eq!;
License: Apache-2.0