# scalars
Minimal numeric traits for Rust. Zero dependencies.
Replacement for `num-traits` with single-purpose traits instead of monolithic kitchen-sink traits.
## Traits
### Identities & Operations
- `Zero` — `fn zero()`, `fn is_zero()`
- `One` — `fn one()`, `fn is_one()`
- `Inv` — `fn inv()` with associated `Output` type
- `Sqrt` — `fn sqrt()`
### Exponential
- `Exp` — `fn exp()`, `fn exp2()` with associated `Output` type (supports Bivector → Rotor)
### Trigonometry
- `Trigonometry` — `fn sin_cos() -> [Self; 2]`, `fn sin()`, `fn cos()`, `fn tan()`
- `InverseTrigonometry` — `fn asin()`, `fn acos()`, `fn atan()`, `fn atan2()`
### Ordering
- `Clamp` — `fn min()`, `fn max()`, `fn clamp()`
### Parsing
- `FromStrRadix` — `fn from_str_radix()` with associated `Error` type
### Supertraits
- `Numeric` — `Copy + PartialEq + Add + Sub + Mul + Zero + One`
- `Integer` — `Numeric + Eq + Ord + Div + Rem`
- `Real` — `Numeric + PartialOrd + Div + Neg + Inv + Sqrt + Exp + Trigonometry + InverseTrigonometry + Clamp`
All supertraits have blanket implementations.
## Implementations
- `f32`, `f64` — all traits including `Real`
- `i8`..`i128`, `u8`..`u128`, `isize`, `usize` — `Zero`, `One`, `Clamp`, `FromStrRadix`, `Integer`
## Example
```rust
use scalars::{Real, Zero};
fn normalize<T: Real>(values: &mut [T]) {
let sum: T = values.iter().copied().fold(T::zero(), |accumulator, value| accumulator + value);
if !sum.is_zero() {
for value in values {
*value = *value / sum;
}
}
}
```
## AI-assisted development
This crate is designed for use with AI coding assistants. Each trait covers exactly one concept, all supertraits use blanket implementations, and there is no implicit behavior. The `Exp` trait's associated `Output` type enables geometric algebra types (Bivector → Rotor) alongside scalar floats.