summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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.