Crate one_based

Source
Expand description

Provides OneBased* unsigned int types, which wraps several integers as 1-based index.

Example:

let v: OneBasedU32 = "5".parse().unwrap();
assert_eq!(v.as_zero_based(), 4);
assert_eq!(v.as_one_based(), NonZeroU32::new(5).unwrap());

let v: Result<OneBasedU32, OneBasedError> = OneBasedU32::from_one_based(0);
assert_eq!(v.unwrap_err(), OneBasedError::ZeroIndex);

Structs§

OneBasedU8
Represents 1-based index of u8.
OneBasedU16
Represents 1-based index of u16.
OneBasedU32
Represents 1-based index of u32.
OneBasedU64
Represents 1-based index of u64.
OneBasedU128
Represents 1-based index of u128.
OneBasedUsize
Represents 1-based index of usize.

Enums§

OneBasedError
Error type used when converting integer to OneBased* types.