diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -23,21 +23,17 @@ use rand::distributions::{Bernoulli, Distribution}; use std::io::{stdout, BufWriter, StdoutLock, Write}; -const TRANSPARENT_SQUARE: &str = " "; -const OPAQUE_SQUARE: &str = "█"; +const TRANSPARENT_SQUARE: &[u8] = " ".as_bytes(); +const OPAQUE_SQUARE: &[u8] = "█".as_bytes(); fn print_square(stream: &mut BufWriter<StdoutLock>, is_opaque: bool) { - stream - .write_all( - if is_opaque { - OPAQUE_SQUARE - } else { - TRANSPARENT_SQUARE - } - .to_string() - .as_bytes(), - ) - .unwrap(); + let square = if is_opaque { + OPAQUE_SQUARE + } else { + TRANSPARENT_SQUARE + }; + + stream.write_all(square).unwrap(); } /// Prints a two-colored Hitomezashi stitch pattern of the specified dimensions. |