1 2 3 4 5 6 7 8 9 10 11
pub fn enumerate_names(base: &str) -> impl Iterator<Item = String> { let mut stage = 0; std::iter::from_fn(move || { stage += 1; match stage { 1 => base.to_owned().into(), 2.. => format!("{}_{}", base, stage).into(), _ => unreachable!(), } }) }