numaxiom 0.0.1

Const-friendly numeric traits for expressing ranges, signs, and constants in no_std contexts.
Documentation
  • Coverage
  • 55.71%
    39 out of 70 items documented0 out of 0 items with examples
  • Size
  • Source code size: 40.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • numaxiom/numaxiom
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Mikou-2A

numaxiom

Crates.io Docs.rs License: MIT OR Apache-2.0 CI

⚠️ Pre-release: version 0.0.1 is experimental. APIs and crate layout may change without backward compatibility guarantees.

numaxiom is a lightweight collection of numeric traits for expressing ranges, signs, and constants at the type level. It is not a num-traits compatibility layer; the goal is a const-friendly set of axioms that can be used in no_std contexts.

Key traits

  • Zero / One / Two (and *_Const): fetch basic constants at runtime or in const contexts. Const and non-const forms are implemented explicitly rather than derived from each other; primitives ship with both.
  • MinValue / MaxValue / Bounded: upper and lower bounds; Bounded::bounds() returns the pair.
  • Sign markers: NonNegative, NonPositive, AnySign, Positive, Negative, NonZero, etc.
  • Operations: Abs, Signum, Reciprocal, Sqrt, Clamp, Epsilon.
  • Saturating ops: SaturatingAdd, SaturatingSub, SaturatingMul.
  • Checked ops: CheckedAdd, CheckedSub, CheckedMul, CheckedDiv, CheckedRem, CheckedNeg.

Usage

use core::ops::Add;
use numaxiom::{Abs, Clamp, NonNegative, One, Two, Zero};

fn normalize<T>(value: T) -> T
where
    T: NonNegative + Abs + One + Two + Zero + Clamp + Add<Output = T>,
{
    let denominator = T::one() + T::two();
    value.abs().clamp(T::zero(), denominator)
}