Skip to content

JohnScience/zero_based_index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Newtype offering some utility methods for zero-based indices

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks