creature_feature 0.2.0

Composable n-gram combinators that are ergonomic and bare-metal fast.
Documentation
//! Parity check: every binding that compiled in the old `src/main.rs`
//! (live lines + the commented lines that nonetheless compiled at HEAD)
//! must still compile/run. `chars_of(s)` -> inline `s.chars().collect()`,
//! `Feature64` -> `HashedAs<u64>`; both were internal-only symbols.
use creature_feature::ftzrs::{gap_gram, n_gram, n_slice};
use creature_feature::traits::Ftzr;
use creature_feature::HashedAs;

// Types are reproduced verbatim from the historical `main.rs`; complexity is the point.
#[allow(clippy::type_complexity)]
#[test]
fn old_main_bindings_still_compile() {
    let four_bytes: [u8; 4] = [1, 2, 3, 4];
    let sentence: Vec<&str> = "one fish two fish red fish blue fish"
        .split_ascii_whitespace()
        .collect();
    let gram = n_gram::<2>();
    let kip = gap_gram(gram, 2, gram);
    let skip = gap_gram(kip, 2, kip);
    let vec = vec![1i32, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17];
    let az = "abcdefghijklmnopqrstuvqxyz";
    let az_chars: Vec<char> = az.chars().collect();

    // ---- live lines A..J ----
    let _a: Vec<HashedAs<u64>> = n_slice(2).featurize(&four_bytes[..]); // A (Feature64)
    let _b: Vec<&[u8]> = n_slice(2).featurize(&four_bytes[..]); // B
    let _c: Vec<&[&str]> = n_slice(3).featurize(&sentence); // C
    let _d: Vec<[i32; 2]> = gram.featurize(&vec); // D
    let _e: Vec<(Vec<i32>, Vec<i32>)> = kip.featurize(vec.as_slice()); // E
    let _f: Vec<([char; 2], [char; 2])> = kip.featurize(az_chars.as_slice()); // F (chars_of)
    let _g: Vec<(String, String)> = kip.featurize(az_chars.as_slice()); // G (chars_of)
    let _h: Vec<(String, String)> = kip.featurize(az); // H
    let _i: Vec<(([i32; 2], [i32; 2]), ([i32; 2], [i32; 2]))> = skip.featurize(vec.as_slice()); // I
    let _j: Vec<(&[i32], &[i32])> = gap_gram(n_slice(5), 4, n_slice(2)).featurize(vec.as_slice()); // J

    // ---- commented-but-compiled-at-HEAD lines ----
    let _m: Vec<([i32; 2], [i32; 2])> = kip.featurize(&vec); // M (&Vec input)
    let _n: Vec<([i32; 2], [i32; 2], [i32; 2], [i32; 2])> = skip.featurize(vec.as_slice()); // N (flat 4-tuple)
    let _p: Vec<String> = gram.featurize(&az_chars); // P (chars_of)

    // touch a couple to prove they ran, not just typed
    assert!(!_a.is_empty());
    assert_eq!(_d.len(), 16);
    assert!(!_h.is_empty());
}