use iec16022::DataMatrix; use std::env::args_os; use std::os::unix::ffi::OsStringExt; fn main() { let data = args_os() .skip(1) // program name .map(|arg| arg.into_vec()) .collect::>() .join(&b' '); let dmtx = DataMatrix::encode(&data).unwrap(); let capacity = (dmtx.width() + 1) * dmtx.height(); let mut out = String::with_capacity(capacity); for row in (0..dmtx.height()).rev() { for col in 0..dmtx.width() { if dmtx.get(row, col) { out.push('*'); } else { out.push(' '); } } out.push('\n'); } debug_assert!( capacity == out.capacity(), "caculated capacity is not correct" ); print!("{}", out); }