Skip to content

MaxMahem/size_guess

size_guess

Build Docs dependency status codecov GitHub License

Provides a one-line way to estimate the upper size of an iterator.

The guess is based on the iterator's upper bound hint, if present; otherwise, it is based on the lower bound.

Usage

use size_guess::SizeGuess;

// exact size iterators will return an accurate guess
let iter = 1..10;
let guess = iter.size_guess();
assert_eq!(guess, iter.len());

// unbounded iterators will return the lower bound, which may be very large
let iter = std::iter::repeat(());
let guess = iter.size_guess();
assert_eq!(guess, usize::MAX);

About

Provides a way to get a guess of the size of an iterator

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors

Languages