Crate padded_iterator
source ·Expand description
This crate provides an iterator that pads the end of the iterator with a value up to a given length.
Examples:
use padded_iterator::PaddedIterBuilder;
let mut iter = PaddedIterBuilder::new()
.iter(vec![1, 2, 3].into_iter())
.length(5)
.pad(0)
.build()
.unwrap();
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(3));
assert_eq!(iter.next(), Some(0));
assert_eq!(iter.next(), Some(0));
assert_eq!(iter.next(), None);
use padded_iterator::PaddedIter;
let mut iter = PaddedIter::from((vec![1, 2, 3].into_iter(), 5, 0));
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(3));
assert_eq!(iter.next(), Some(0));
assert_eq!(iter.next(), Some(0));
assert_eq!(iter.next(), None);
Structs
- An iterator which has been padded to a given length.
- A builder for PaddedIter.
Enums
- An error that can occur when building a padded iterator.