🎨 cargo fmt

main
Shad Amethyst 2 years ago
parent 92d5b882a4
commit 949da3cd14
Signed by: amethyst
GPG Key ID: D970C8DD1D6DEE36

@ -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));
}
}
}

@ -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};

@ -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);

@ -11,7 +11,7 @@ impl Value {
pub fn as_number(&self) -> Option<f64> {
match self {
Value::Number(x) => Some(*x),
_ => None
_ => None,
}
}

@ -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);

@ -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
};

Loading…
Cancel
Save