#iterator #pair #adjacent #no-std

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

#8 in #iter

Download history 13/week @ 2024-07-22 27/week @ 2024-07-29 31/week @ 2024-08-05 5/week @ 2024-08-12 47/week @ 2024-08-19 8/week @ 2024-08-26 15/week @ 2024-09-02 28/week @ 2024-09-09 2/week @ 2024-09-16 33/week @ 2024-09-23 16/week @ 2024-09-30 53/week @ 2024-10-07 59/week @ 2024-10-14 11/week @ 2024-11-04

79 downloads per month
Used in jikken

ISC license

12KB
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