use std::io;
use io::BufWriter;
use io::Write;
use io::BufRead;
pub fn str2slug<S>(original: S) -> String
where
S: AsRef<str>,
{
slug::slugify(original)
}
pub fn strings2slugs2writer<I, W>(strings: I, mut wtr: W) -> Result<(), io::Error>
where
I: Iterator<Item = Result<String, io::Error>>,
W: Write,
{
for rline in strings {
let line: String = rline?;
let converted: String = str2slug(line);
writeln!(&mut wtr, "{converted}")?;
}
wtr.flush()
}
pub fn stdin2strings2slugs2stdout() -> Result<(), io::Error> {
let o = io::stdout();
let mut ol = o.lock();
strings2slugs2writer(io::stdin().lock().lines(), BufWriter::new(&mut ol))?;
ol.flush()
}