From 52080c0ad0436ed591bbb47fdb7887c3d57c1170 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Tue, 25 Jun 2024 22:10:48 +0200 Subject: [PATCH] minor tweaks to examples --- crates/servicepoint/examples/brightness_tester.rs | 15 +++++++-------- crates/servicepoint/examples/game_of_life.rs | 13 ++++++------- crates/servicepoint/examples/moving_line.rs | 14 +++++++------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/crates/servicepoint/examples/brightness_tester.rs b/crates/servicepoint/examples/brightness_tester.rs index 650a428..c20b82b 100644 --- a/crates/servicepoint/examples/brightness_tester.rs +++ b/crates/servicepoint/examples/brightness_tester.rs @@ -2,8 +2,8 @@ use clap::Parser; -use servicepoint::Command::BitmapLinearWin; use servicepoint::*; +use servicepoint::Command::BitmapLinearWin; #[derive(Parser, Debug)] struct Cli { @@ -19,13 +19,12 @@ fn main() { let mut pixels = PixelGrid::max_sized(); pixels.fill(true); - connection - .send(BitmapLinearWin( - Origin::new(0, 0), - pixels, - CompressionCode::Uncompressed, - )) - .expect("send failed"); + let command = BitmapLinearWin( + Origin::new(0, 0), + pixels, + CompressionCode::Uncompressed, + ); + connection.send(command).expect("send failed"); let max_brightness = usize::from(u8::from(Brightness::MAX)); let mut brightnesses = BrightnessGrid::new(TILE_WIDTH, TILE_HEIGHT); diff --git a/crates/servicepoint/examples/game_of_life.rs b/crates/servicepoint/examples/game_of_life.rs index 61ce108..29507ce 100644 --- a/crates/servicepoint/examples/game_of_life.rs +++ b/crates/servicepoint/examples/game_of_life.rs @@ -23,13 +23,12 @@ fn main() { let mut field = make_random_field(cli.probability); loop { - connection - .send(Command::BitmapLinearWin( - Origin::new(0, 0), - field.clone(), - CompressionCode::Lzma, - )) - .expect("could not send"); + let command = Command::BitmapLinearWin( + Origin::new(0, 0), + field.clone(), + CompressionCode::Lzma, + ); + connection.send(command).expect("could not send"); thread::sleep(FRAME_PACING); field = iteration(field); } diff --git a/crates/servicepoint/examples/moving_line.rs b/crates/servicepoint/examples/moving_line.rs index caeb92d..5682be4 100644 --- a/crates/servicepoint/examples/moving_line.rs +++ b/crates/servicepoint/examples/moving_line.rs @@ -23,13 +23,13 @@ fn main() { for y in 0..PIXEL_HEIGHT { pixels.set((y + x_offset) % PIXEL_WIDTH, y, true); } - connection - .send(Command::BitmapLinearWin( - Origin::new(0, 0), - pixels.clone(), - CompressionCode::Lzma, - )) - .unwrap(); + + let command = Command::BitmapLinearWin( + Origin::new(0, 0), + pixels.clone(), + CompressionCode::Lzma, + ); + connection.send(command).expect("send failed"); thread::sleep(FRAME_PACING); } }