Ranged integers [nightly only]
Provides the single generic type Ranged<MIN, MAX> representing an integer
within a specified range. It automatically chooses the data size guided by
the range specified (so Ranged<-50, 50> is of 1 byte while
Ranged<-20_000, 100_000> is of 4 bytes) and supports the arithmetic operations
with automatic bound recalculation.
The conversion and arithmetic functions catch the errors such as possible overflow and zero division at compile time.
Example
extern crate ranged_integers;
use *;
// Consider a simple race game. The player rolls a
// die and then moves forward, backward or forward
// with the double speed according to some rules.
// Get a die roll using a standard random number generator
// Calculate where the player must move
// The result fits the range -6..=12
6, 12>