Expand description
ranged-num is a crate for representing a single number that is in some compile-time known range of values. You can use any underlying numeric type to hold the actual value. The main type to look at is Ranged.
Example:
use typenum::{N2, P3, P4};
use ranged_num::Ranged;
let ranged = Ranged::<N2, P4, isize>::new::<P3>();
assert_eq!(ranged.value(), 3);Modules§
- reexports
- These are used by a macro. In order for them to be accessible to the macro I re-exported them. If you know of a better way to do this, let me know.
Macros§
- define_
ranged_ enum - Define a new enum which can be convered to and from a Ranged usize.
Structs§
- Ranged
- Holds a single value between
MinandMax. That value is stored in a single variable of typeUnderlying.
Traits§
- AddU
typenumdoesn’t currently allow you to easily add anIntegerwith anUnsigned. TheAddUtrait lets you add someUnsignedto bothIntegers andUnsigneds.- CanMake
typenumdoesn’t currently allow you to easily specify any numbers (signed or unsigned) that can be converted to a given type. I’ve addedCanMake<V>as a trait to indicate which types can easily make a runtime value of typeVto use in type bounds.
Type Aliases§
- UZeroTo
- Represent a usize in
[0, Max](inclusive).