aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorNicholas Johnson <nick@nicholasjohnson.ch>2024-05-13 00:00:00 +0000
committerNicholas Johnson <nick@nicholasjohnson.ch>2024-05-13 00:00:00 +0000
commit71c025f68971425b92cd860bdadf23b98d4d303eccc7cd9ab14baacd5e83adf9 (patch)
treebd04c03bd760157759c7de37b721e3b265c6e84633ef7169da8639be34afb1b1 /src/lib.rs
parentc0a9f0a0f8085f8feb2e97b59f4538e1fc48d1fcfa08e970d11dab84a9d9fc04 (diff)
downloadhitomezashi-rs-71c025f68971425b92cd860bdadf23b98d4d303eccc7cd9ab14baacd5e83adf9.tar.gz
hitomezashi-rs-71c025f68971425b92cd860bdadf23b98d4d303eccc7cd9ab14baacd5e83adf9.zip
Clean up syntax
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 3d7cf2d..e5118be 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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.