#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

#430 in Rust patterns

Download history 140/week @ 2024-07-27 140/week @ 2024-08-03 142/week @ 2024-08-10 132/week @ 2024-08-17 153/week @ 2024-08-24 148/week @ 2024-08-31 944/week @ 2024-09-07 969/week @ 2024-09-14 650/week @ 2024-09-21 701/week @ 2024-09-28 582/week @ 2024-10-05 679/week @ 2024-10-12 1359/week @ 2024-10-19 865/week @ 2024-10-26 770/week @ 2024-11-02 762/week @ 2024-11-09

3,872 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