#first #last #iterator #is-last

no-std iter-identify_first_last

A helper iterator, flagging first and last elements

4 releases (2 breaking)

0.2.1 Feb 19, 2024
0.2.0 Jun 24, 2023
0.1.0 Dec 26, 2022
0.0.1 Dec 11, 2022

#692 in Rust patterns

Download history 236/week @ 2024-03-17 244/week @ 2024-03-24 277/week @ 2024-03-31 263/week @ 2024-04-07 243/week @ 2024-04-14 234/week @ 2024-04-21 189/week @ 2024-04-28 176/week @ 2024-05-05 199/week @ 2024-05-12 178/week @ 2024-05-19 163/week @ 2024-05-26 171/week @ 2024-06-02 150/week @ 2024-06-09 174/week @ 2024-06-16 161/week @ 2024-06-23 50/week @ 2024-06-30

556 downloads per month
Used in 6 crates (5 directly)

MIT/Apache

10KB
125 lines

maintenance: actively developed

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");
}

lib.rs:

Feature flags

Dependencies

~175KB