-
Notifications
You must be signed in to change notification settings - Fork 335
Open
Description
Reading the docs for pad_using
:
Return an iterator adaptor that pads the sequence to a minimum length of min by filling missing elements using a closure f.
And the examples:
let it = (0..5).pad_using(10, |i| 2*i);
itertools::assert_equal(it, vec![0, 1, 2, 3, 4, 10, 12, 14, 16, 18]);
It seems like if the padding is greater than the iterator's length, it's padded up to a minimum of those items with the given function. That makes sense.
I tried out pad_using
, and padded to an iterator of [1]:
use itertools::Itertools;
#[test]
fn pad_tail_bug() {
let mut iter = vec![].into_iter().pad_using(1, |_| 1);
itertools::assert_equal(iter.clone(), vec![1]);
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next_back(), None);
}
This is the error message I get running this test:
running 1 test
thread 'pad_tail_bug' panicked at tests/pad_using_bug.rs:10:5:
assertion `left == right` failed
left: Some(1)
right: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test pad_tail_bug ... FAILED
failures:
failures:
pad_tail_bug
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
error: test failed, to rerun pass `--test pad_using_bug`
I would assume that calling next
and then next_back
should return Some(1)
for an iterator with only one element and then the next item should be None, no?
Metadata
Metadata
Assignees
Labels
No labels