#iterator #first #last #is-last

no-std iter-identify_first_last

A helper iterator, flagging first and last elements

6 releases

0.2.3 Sep 8, 2024
0.2.2 Sep 8, 2024
0.2.1 Feb 19, 2024
0.2.0 Jun 24, 2023
0.0.1 Dec 11, 2022

#436 in Rust patterns

Download history 134/week @ 2024-08-22 162/week @ 2024-08-29 772/week @ 2024-09-05 891/week @ 2024-09-12 766/week @ 2024-09-19 699/week @ 2024-09-26 599/week @ 2024-10-03 653/week @ 2024-10-10 1352/week @ 2024-10-17 834/week @ 2024-10-24 779/week @ 2024-10-31 774/week @ 2024-11-07 738/week @ 2024-11-14 749/week @ 2024-11-21 731/week @ 2024-11-28 618/week @ 2024-12-05

2,939 downloads per month
Used in 12 crates (5 directly)

MIT/Apache

10KB
126 lines

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

lib.rs:

Feature flags

Dependencies

~175KB