zero_based_index

Crates.iozero_based_index
lib.rszero_based_index
version0.2.2
sourcesrc
created_at2022-01-11 04:23:21.928878
updated_at2022-10-14 07:25:31.145383
descriptionNewtype offering some utility methods for zero-based indices.
homepage
repositoryhttps://github.com/JohnScience/zero_based_index
max_upload_size
id512051
size24,418
Dmitrii - Demenev (JohnScience)

documentation

https://docs.rs/zero_based_index

README

crates.io crates.io crates.io

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 zero_based_index::ZBI;

let zbi = ZBI(2usize);
assert_eq!(zbi.to_len(), Some(3));

Base case with zero_based_index::AsZBI

use zero_based_index::{ZBI, AsZBI};

let zbi = 2.as_zbi();
assert_eq!(zbi.to_len(), Some(3));

Corner case

use zero_based_index::ZBI;

let zbi = ZBI(usize::MAX);
assert_eq!(zbi.to_len(), None);

Features

  • Check the list of feature flags here.
  • Learn about features in general here.

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.
Commit count: 30

cargo fmt