#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

#439 in Rust patterns

Download history 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 768/week @ 2024-11-09 742/week @ 2024-11-16 751/week @ 2024-11-23 709/week @ 2024-11-30 715/week @ 2024-12-07 792/week @ 2024-12-14 557/week @ 2024-12-21 398/week @ 2024-12-28 361/week @ 2025-01-04

2,202 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