chadtmiller.com/knotless
Git hosted in your atproto account, on any stock PDS, fast enough for agents.
git clone knotless://chadtmiller.com/knotlessneeds the knotless git helper. set it up
//! Splitting text into the things tally counts.
/// The words of `line`: runs of anything but whitespace.
pub fn words(line: &str) -> usize {
line.split_whitespace().count()
}
/// The lines of `text`. A last line without a newline still counts, and
/// empty input has none.
pub fn lines(text: &str) -> impl Iterator<Item = &str> {
text.lines().filter(|_| !text.is_empty())
}
#[cfg(test)]
mod tests {
#[test]
fn empty_input_has_no_lines() {
assert_eq!(super::lines("").count(), 0);
}
}