#iterator #iter #pair #no-std #adjacent

no-std adjacent-pair-iterator

An iterator over adjacent pairs in another iterator

4 releases (1 stable)

1.0.0 Nov 9, 2021
0.1.2 May 24, 2019
0.1.1 May 24, 2019
0.1.0 May 24, 2019

#2557 in Rust patterns

Download history 15/week @ 2023-01-26 6/week @ 2023-02-02 11/week @ 2023-02-09 27/week @ 2023-02-16 3/week @ 2023-02-23 4/week @ 2023-03-02 6/week @ 2023-03-09 23/week @ 2023-03-16 144/week @ 2023-03-23 70/week @ 2023-03-30 93/week @ 2023-04-06 39/week @ 2023-04-13 57/week @ 2023-04-20 36/week @ 2023-04-27 62/week @ 2023-05-04 41/week @ 2023-05-11

197 downloads per month

ISC license

11KB
299 lines

adjacent-pair-iterator

A #![no_std] library that takes an iterator and turns it into an iterator over adjacent pairs.

Minimum rust version (MSRV)

This library works with Rust versions since 1.31.

Example:

use adjacent_pair_iterator::AdjacentPairIterator;

pub fn main() {
	let vector = vec![1, 2, 3, 4];
	for pair in vector.adjacent_pairs() {
		println!("{:?}", pair);
	}
}

Prints:

(1, 2)
(2, 3)
(3, 4)

lib.rs:

adjacent-pair-iterator

A library that takes an iterator and turns it into an iterator over adjacent pairs.

Example:

use adjacent_pair_iterator::AdjacentPairIterator;

let vector = vec![1, 2, 3, 4];
let mut iterator = vector.adjacent_pairs();

assert_eq!((1, 2), iterator.next().unwrap());
assert_eq!((2, 3), iterator.next().unwrap());
assert_eq!((3, 4), iterator.next().unwrap());

assert_eq!(None, iterator.next());

No runtime deps