#pair #iterator #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

#869 in Rust patterns

Download history 1637/week @ 2024-11-30 1470/week @ 2024-12-07 695/week @ 2024-12-14 4545/week @ 2024-12-21 1468/week @ 2024-12-28 1590/week @ 2025-01-04 689/week @ 2025-01-11 558/week @ 2025-01-18 1322/week @ 2025-01-25 2890/week @ 2025-02-01 659/week @ 2025-02-08 2753/week @ 2025-02-15 2284/week @ 2025-02-22 1716/week @ 2025-03-01 1764/week @ 2025-03-08 2610/week @ 2025-03-15

8,873 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