Crates.io | zero_based_index |
lib.rs | zero_based_index |
version | 0.2.2 |
source | src |
created_at | 2022-01-11 04:23:21.928878 |
updated_at | 2022-10-14 07:25:31.145383 |
description | Newtype offering some utility methods for zero-based indices. |
homepage | |
repository | https://github.com/JohnScience/zero_based_index |
max_upload_size | |
id | 512051 |
size | 24,418 |
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
use zero_based_index::ZBI;
let zbi = ZBI(2usize);
assert_eq!(zbi.to_len(), Some(3));
zero_based_index::AsZBI
use zero_based_index::{ZBI, AsZBI};
let zbi = 2.as_zbi();
assert_eq!(zbi.to_len(), Some(3));
use zero_based_index::ZBI;
let zbi = ZBI(usize::MAX);
assert_eq!(zbi.to_len(), None);