[][src]Module af_lib::math

Traits and utilities for working with numbers.

Traits

AsPrimitive

A generic interface for casting between machine scalars with the as operator, which admits narrowing and precision loss. Implementers of this trait AsPrimitive should behave like a primitive numeric type (e.g. a newtype around another primitive), and the intended conversion must never fail.

FloatExt

An extension trait for f32 and f64.

Number

A trait for types that implement all the basic operations of a number.

One

Defines a multiplicative identity element for Self.

Zero

Defines an additive identity element for Self.

Functions

clamp

Clamps a number so that it is between a minimum and maximum bound.

clamp_mut

Clamps a number in-place so that it is between a minimum and maximum bound.

one

Returns the multiplicative identity, 1.

zero

Returns the additive identity, 0.