const-identities 0.1.0

Exposes num::{Zero, One} as associated constants
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented1 out of 3 items with examples
  • Size
  • Source code size: 3.64 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.41 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ecstatic-morse

Extends the traits from num_traits::identities to use an associated constant.

Examples

#![feature(const_fn)]

# extern crate const_identities;
use const_identities::ConstZero;

pub struct Newtype<T>(pub T);

impl<T: ConstZero> Newtype<T> {
    pub const fn zero() -> Self {
        Newtype(T::ZERO)
    }
}

assert_eq!(Newtype::<i32>::zero().0, 0);