#iterator #element #preserving #exact-size-iterator

chain-one

A way to add a single element to an iterator while preserving ExactSizeIterator

1 unstable release

Uses old Rust 2015

0.1.0 Mar 27, 2019

#14 in #preserving

Unlicense

4KB
76 lines

chain_one

Annoyed that you [T; N] doesn't implement IntoIterator<Item = T>? Annoyed that Chain doesn't implement ExactSizeIterator? Do I have a project for you!

assert_eq!(iter![1, 2, 3, 4, 5].collect::<Vec<_>>(), vec![1, 2, 3, 4, 5]);
assert_eq!(iter![1, 2, 3, 4, 5].rev().collect::<Vec<_>>(), vec![5, 4, 3, 2, 1]);
assert_eq!((0..5).chain_one(0).collect::<Vec<_>>(), vec![0, 1, 2, 3, 4, 0]);

No runtime deps