From da3c2c7a0f5cbda8bf31f4748563365ef197d464 Mon Sep 17 00:00:00 2001 From: Adam Lusch Date: Thu, 29 Feb 2024 19:27:03 -0600 Subject: [PATCH] Cleanup --- src/main.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index dd99695..98d3292 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,11 +28,11 @@ pub struct Options { #[structopt(short = "t", long = "24hour")] pub use_24_hour: bool, - /// Show day of week (WED 28) after the time instead of month (FEB 28) + /// Shows day of week (WED 28) after the time instead of month (FEB 28) #[structopt(short = "d", long = "dayofweek")] pub show_day_of_week: bool, - /// Show the current time and exit (suitable for use with cron, etc.) + /// Shows the current time and exits (suitable for use with cron, etc.) #[structopt(short = "o", long = "oneshot")] pub one_shot: bool, } @@ -43,20 +43,19 @@ fn main() -> Result<()> { let options = Options::from_args(); let address = Address(options.address); - let bus_rc: Rc>; - if options.port.eq_ignore_ascii_case("virtual") { + let bus: Rc> = if options.port.eq_ignore_ascii_case("virtual") { let bus = VirtualSignBus::new(iter::once(VirtualSign::new(address))); - bus_rc = Rc::new(RefCell::new(bus)); + Rc::new(RefCell::new(bus)) } else { let port = serial::open(&options.port) .context(format!("Failed to open serial port `{}`", &options.port))?; let bus = SerialSignBus::try_new(port).context("Failed to create bus")?; - bus_rc = Rc::new(RefCell::new(bus)); - } + Rc::new(RefCell::new(bus)) + }; // TODO: Allow configuring the type (which will also require different ways of // generating the output and possibly fonts to adapt to different sizes). - let sign = Sign::new(bus_rc.clone(), address, SignType::Max3000Side90x7); + let sign = Sign::new(bus.clone(), address, SignType::Max3000Side90x7); sign.configure().context("Failed to configure sign")?; let clock = Clock::try_new(sign, options.use_24_hour, options.show_day_of_week)?;