diff options
author | Nicholas Johnson <nick@nicholasjohnson.ch> | 2024-05-13 00:00:00 +0000 |
---|---|---|
committer | Nicholas Johnson <nick@nicholasjohnson.ch> | 2024-05-13 00:00:00 +0000 |
commit | 71c025f68971425b92cd860bdadf23b98d4d303eccc7cd9ab14baacd5e83adf9 (patch) | |
tree | bd04c03bd760157759c7de37b721e3b265c6e84633ef7169da8639be34afb1b1 /src/lib.rs | |
parent | c0a9f0a0f8085f8feb2e97b59f4538e1fc48d1fcfa08e970d11dab84a9d9fc04 (diff) | |
download | hitomezashi-rs-71c025f68971425b92cd860bdadf23b98d4d303eccc7cd9ab14baacd5e83adf9.tar.gz hitomezashi-rs-71c025f68971425b92cd860bdadf23b98d4d303eccc7cd9ab14baacd5e83adf9.zip |
Clean up syntax
Diffstat (limited to 'src/lib.rs')
-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. |