iter-identify_first_last

Crates.ioiter-identify_first_last
lib.rsiter-identify_first_last
version0.2.3
sourcesrc
created_at2022-12-11 11:44:28.622631
updated_at2024-09-08 18:57:40.877821
descriptionA helper iterator, flagging first and last elements.
homepage
repositoryhttps://github.com/A1-Triard/iter-identify_first_last
max_upload_size
id734305
size11,854
Warlock (A1-Triard)

documentation

https://docs.rs/iter-identify_first_last/

README

maintenance: passively maintained

iter-identify_first_last

A helper iterator, flagging first and last elements.

use iter_identify_first_last::IteratorIdentifyFirstLastExt;
use std::fmt::Write;

fn main() {
    let list = [1, 2, 3, 4, 5, 6];
    let mut string = String::new();
    for (is_first, item) in list.iter().identify_first() {
        if !is_first {
            string.push(' ');
        }
        write!(string, "{item}").unwrap();
    }
    assert_eq!(string, "1 2 3 4 5 6");
}
Commit count: 29

cargo fmt