From 949da3cd14865cb7cfaed59600db64cc9c1c63f4 Mon Sep 17 00:00:00 2001 From: Adrien Burgun Date: Fri, 24 Jun 2022 11:15:51 +0200 Subject: [PATCH] :art: cargo fmt --- stackline/src/context.rs | 12 ++++++------ stackline/src/lib.rs | 2 +- stackline/src/pane.rs | 11 ++++++++++- stackline/src/signal.rs | 2 +- stackline/src/text.rs | 7 +++---- stackline/src/tile/wire.rs | 8 ++++---- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/stackline/src/context.rs b/stackline/src/context.rs index 22f2daa..8e3eb72 100644 --- a/stackline/src/context.rs +++ b/stackline/src/context.rs @@ -92,9 +92,7 @@ impl<'a> UpdateContext<'a> { position, state: tile.state(), signal: tile.take_signal(), - pane: unsafe { - NonNull::new_unchecked(&mut *pane) - }, + pane: unsafe { NonNull::new_unchecked(&mut *pane) }, commit, }; @@ -329,9 +327,11 @@ impl<'a> UpdateContext<'a> { pub fn keep(&mut self) { unsafe { // SAFETY: we only access self.pane[self.position].signal, not self.pane[self.position].cell - self.pane.as_mut().get_mut(self.position).unwrap_or_else(|| unreachable!()).set_signal( - std::mem::take(&mut self.signal) - ); + self.pane + .as_mut() + .get_mut(self.position) + .unwrap_or_else(|| unreachable!()) + .set_signal(std::mem::take(&mut self.signal)); } } } diff --git a/stackline/src/lib.rs b/stackline/src/lib.rs index 200a42e..d2a6a3e 100644 --- a/stackline/src/lib.rs +++ b/stackline/src/lib.rs @@ -35,7 +35,7 @@ pub mod prelude { pub use crate::pane::Pane; pub use crate::World; - pub use crate::text::{TextSurface, TextChar}; + pub use crate::text::{TextChar, TextSurface}; pub use crate::context::UpdateContext; pub use crate::signal::{Signal, Value}; diff --git a/stackline/src/pane.rs b/stackline/src/pane.rs index f9ce96a..48e9372 100644 --- a/stackline/src/pane.rs +++ b/stackline/src/pane.rs @@ -338,7 +338,16 @@ mod test { use Orientation::*; let mut surface = TextSurface::new(3, 3); - let mut pane = test_tile_setup!(2, 2, [Wire::new(Horizontal), Wire::new(Vertical), Wire::new(Any), ()]); + let mut pane = test_tile_setup!( + 2, + 2, + [ + Wire::new(Horizontal), + Wire::new(Vertical), + Wire::new(Any), + () + ] + ); test_set_signal!(pane, (0, 0), Direction::Right); pane.draw(0, 0, &mut surface); diff --git a/stackline/src/signal.rs b/stackline/src/signal.rs index 0e81cd6..4fd49f4 100644 --- a/stackline/src/signal.rs +++ b/stackline/src/signal.rs @@ -11,7 +11,7 @@ impl Value { pub fn as_number(&self) -> Option { match self { Value::Number(x) => Some(*x), - _ => None + _ => None, } } diff --git a/stackline/src/text.rs b/stackline/src/text.rs index bf8f496..c8397db 100644 --- a/stackline/src/text.rs +++ b/stackline/src/text.rs @@ -41,7 +41,7 @@ impl TextChar { State::Active => Srgb::new(220, 255, 255), State::Dormant => Srgb::new(100, 60, 60), }, - bg: None + bg: None, } } } @@ -51,7 +51,7 @@ impl Default for TextChar { Self { ch: ' ', fg: Srgb::new(255, 255, 255), - bg: None + bg: None, } } } @@ -136,8 +136,7 @@ impl std::fmt::Display for TextSurface { for y in 0..self.height { for x in 0..self.width { let ch = self.chars[y * self.width + x]; - let mut string = String::from(ch.ch) - .truecolor(ch.fg.red, ch.fg.green, ch.fg.blue); + let mut string = String::from(ch.ch).truecolor(ch.fg.red, ch.fg.green, ch.fg.blue); if let Some(bg) = ch.bg { string = string.on_truecolor(bg.red, bg.green, bg.blue); diff --git a/stackline/src/tile/wire.rs b/stackline/src/tile/wire.rs index cddab51..8a5fc18 100644 --- a/stackline/src/tile/wire.rs +++ b/stackline/src/tile/wire.rs @@ -38,7 +38,7 @@ impl Tile for Wire { let ch = match self.0 { Orientation::Horizontal => '-', Orientation::Vertical => '|', - Orientation::Any => '+' + Orientation::Any => '+', }; surface.set(x, y, TextChar::from_state(ch, state)); @@ -119,9 +119,9 @@ impl Tile for Resistor { fn draw(&self, x: usize, y: usize, state: State, surface: &mut TextSurface) { let ch = match self.direction { - Direction::Up => '\u{219f}', // Upwards Two Headed Arrow - Direction::Down => '\u{21a1}', // Downwards Two Headed Arrow - Direction::Left => '\u{219e}', // Leftwards Two Headed Arrow + Direction::Up => '\u{219f}', // Upwards Two Headed Arrow + Direction::Down => '\u{21a1}', // Downwards Two Headed Arrow + Direction::Left => '\u{219e}', // Leftwards Two Headed Arrow Direction::Right => '\u{21a0}', // Rightwards Two Headed Arrow };