#iterator

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

#657 in Rust patterns

Download history 154/week @ 2024-07-02 224/week @ 2024-07-09 192/week @ 2024-07-16 142/week @ 2024-07-23 146/week @ 2024-07-30 135/week @ 2024-08-06 144/week @ 2024-08-13 131/week @ 2024-08-20 162/week @ 2024-08-27 615/week @ 2024-09-03 662/week @ 2024-09-10 1015/week @ 2024-09-17 685/week @ 2024-09-24 617/week @ 2024-10-01 660/week @ 2024-10-08 1291/week @ 2024-10-15

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