#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

#844 in Rust patterns

Download history 837/week @ 2024-10-23 771/week @ 2024-10-30 786/week @ 2024-11-06 736/week @ 2024-11-13 744/week @ 2024-11-20 747/week @ 2024-11-27 700/week @ 2024-12-04 749/week @ 2024-12-11 676/week @ 2024-12-18 442/week @ 2024-12-25 426/week @ 2025-01-01 283/week @ 2025-01-08 59/week @ 2025-01-15 52/week @ 2025-01-22 71/week @ 2025-01-29 67/week @ 2025-02-05

258 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