Crates.io | iter-identify_first_last |
lib.rs | iter-identify_first_last |
version | 0.2.3 |
source | src |
created_at | 2022-12-11 11:44:28.622631 |
updated_at | 2024-09-08 18:57:40.877821 |
description | A helper iterator, flagging first and last elements. |
homepage | |
repository | https://github.com/A1-Triard/iter-identify_first_last |
max_upload_size | |
id | 734305 |
size | 11,854 |
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");
}