fluent-iterable 1.0.1

Fluent extension trait for std Iterator, port of @codibre/fluent-iterable vocabulary: joins, grouping, distinctness, cardinality checks
Documentation
//! Assembles the `FluentIter` trait from the per-family fragments in
//! `src/methods/`. The fragments are trait default methods kept in one file
//! per operation family for maintainability; rustc requires a trait
//! definition to live in a single file, so this build step splices them
//! (plus `00_head.rs`, the trait docs and signature) into one generated
//! file (`src/fluent_iter.rs`, git-ignored) that `lib.rs` includes at
//! module position.
//!
//! The generated file deliberately lives under `src/`, not `OUT_DIR`:
//! cargo-llvm-cov skips everything below `target/`, and the trait bodies
//! must show up in `pnpm test:cov`.

use std::{fs, path::Path};

const HEAD: &str = "src/methods/00_head.rs";
const FAMILIES: [&str; 9] = [
    "grouping",
    "combining",
    "distinct",
    "fallback",
    "sorting",
    "statistics",
    "strings",
    "cardinality",
    "folds",
];

fn main() {
    println!("cargo:rerun-if-changed={HEAD}");
    let mut trait_src =
        String::from("// @generated by build.rs from src/methods/* — do not edit.\n");
    trait_src.push_str(&fs::read_to_string(HEAD).expect("missing src/methods/00_head.rs"));
    for family in FAMILIES {
        let path = format!("src/methods/{family}.rs");
        println!("cargo:rerun-if-changed={path}");
        trait_src.push('\n');
        trait_src.push_str(&fs::read_to_string(&path).expect("missing fragment"));
    }
    trait_src.push_str("\n}\n");
    let target = Path::new(env!("CARGO_MANIFEST_DIR")).join("src/fluent_iter.rs");
    if fs::read_to_string(&target)
        .map(|old| old != trait_src)
        .unwrap_or(true)
    {
        fs::write(&target, trait_src).expect("cannot write src/fluent_iter.rs");
    }
}