clippy + missing files
This commit is contained in:
parent
3f6ff50094
commit
875c0959a4
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,40 @@
|
|||
use std::fmt::{Display, Error, Formatter};
|
||||
pub enum Tile {
|
||||
Empty,
|
||||
Wall,
|
||||
Block,
|
||||
Paddle,
|
||||
Ball,
|
||||
}
|
||||
|
||||
impl Display for Tile {
|
||||
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
|
||||
let c: char = self.into();
|
||||
write!(fmt, "{}", c)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i64> for Tile {
|
||||
fn from(num: i64) -> Self {
|
||||
match num {
|
||||
0 => Tile::Empty,
|
||||
1 => Tile::Wall,
|
||||
2 => Tile::Block,
|
||||
3 => Tile::Paddle,
|
||||
4 => Tile::Ball,
|
||||
_ => unreachable!("Illegal tile ID"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<char> for &Tile {
|
||||
fn into(self) -> char {
|
||||
match self {
|
||||
Tile::Empty => ' ',
|
||||
Tile::Wall => '█',
|
||||
Tile::Block => '⌂',
|
||||
Tile::Paddle => '_',
|
||||
Tile::Ball => '•',
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
use itertools::join;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
use std::hash::BuildHasher;
|
||||
|
||||
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
|
||||
pub struct Position2D {
|
||||
|
@ -23,7 +25,7 @@ fn get_boundaries(input: &[&Position2D]) -> Boundaries {
|
|||
Boundaries { x_min, x_max, y_min, y_max }
|
||||
}
|
||||
|
||||
pub fn draw_ascii<T: std::fmt::Display>(coordinates: &HashMap<Position2D, T>, default: T) -> String {
|
||||
pub fn draw_ascii<T: Display, S: BuildHasher>(coordinates: &HashMap<Position2D, T, S>, default: T) -> String {
|
||||
let b = get_boundaries(&coordinates.keys().collect::<Vec<_>>());
|
||||
join(
|
||||
(b.y_min..=b.y_max).rev().map(|y| {
|
||||
|
|
|
@ -35,12 +35,12 @@ impl IntComputer {
|
|||
|
||||
pub fn step(&mut self) -> IntComputerResult {
|
||||
match self.cmd_buffer.pop().unwrap_or_else(|| self.decode_next()) {
|
||||
Operation::Halt {} => return IntComputerResult::Halt,
|
||||
Operation::Halt {} => IntComputerResult::Halt,
|
||||
op => {
|
||||
if let Some(o) = self.execute(op.to_owned()) {
|
||||
return IntComputerResult::Output(o);
|
||||
if let Some(o) = self.execute(op) {
|
||||
IntComputerResult::Output(o)
|
||||
} else {
|
||||
return IntComputerResult::Continue;
|
||||
IntComputerResult::Continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user