From ce7f5a43ea366d0fe1fea58840b78352dfe2462e Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 13 Apr 2021 11:36:41 +0200 Subject: [PATCH] Slight refactoring. --- src/clock.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/clock.rs b/src/clock.rs index db84e85..590d70e 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -168,20 +168,23 @@ impl Clock { } fn draw_digit_pair( - &self, + &mut self, stdout: &mut RawTerminal, value: u32, pos: &Position, ) -> Result<(), std::io::Error> { + let left = value / 10; + let right = value % 10; + for l in 0..self.font.height { write!(stdout, "{}{} {}", cursor::Goto(pos.col, pos.line + l), // First digit. - self.font.digits[(value / 10) as usize][l as usize], + self.font.digits[left as usize][l as usize], // Second digit. - self.font.digits[(value % 10) as usize][l as usize] + self.font.digits[right as usize][l as usize] )?; } Ok(())