[![crates.io](https://img.shields.io/crates/v/zerobasedindex.svg)][zero_based_index] [![crates.io](https://img.shields.io/crates/d/zerobasedindex.svg)][zero_based_index] [![crates.io](https://img.shields.io/github/workflow/status/JohnScience/zerobasedindex/Stable)][zero_based_index]

Newtype offering some utility methods for zero-based indices

In order to keep the lengths of method names reasonable, several abbreviations have been used, namely * len for length; * int for integer. * zbi for zero-based index.

Examples

Base case

``` use zerobasedindex::ZBI;

let zbi = ZBI(2usize); asserteq!(zbi.tolen(), Some(3)); ```

Base case with zero_based_index::AsZBI

``` use zerobasedindex::{ZBI, AsZBI};

let zbi = 2.aszbi(); asserteq!(zbi.to_len(), Some(3)); ```

Corner case

``` use zerobasedindex::ZBI;

let zbi = ZBI(usize::MAX); asserteq!(zbi.tolen(), None); ```

Features

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.