From 71c025f68971425b92cd860bdadf23b98d4d303eccc7cd9ab14baacd5e83adf9 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Mon, 13 May 2024 00:00:00 +0000 Subject: Clean up syntax --- src/lib.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src') 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, 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. -- cgit v1.2.3