#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

#793 in Rust patterns

Download history 199/week @ 2023-12-23 155/week @ 2023-12-30 193/week @ 2024-01-06 83/week @ 2024-01-13 6/week @ 2024-01-20 10/week @ 2024-02-03 247/week @ 2024-02-10 373/week @ 2024-02-17 307/week @ 2024-02-24 181/week @ 2024-03-02 299/week @ 2024-03-09 232/week @ 2024-03-16 250/week @ 2024-03-23 268/week @ 2024-03-30 228/week @ 2024-04-06

1,005 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