An attempt at making unit structs for Color and piece Shape

My idea was to implement traits on Piece that return sight lines, etc. This has
turned out to be much more complex than I thought it would be. Ultimately, I
don't think it's worth the effort.
This commit is contained in:
Eryn Wells 2024-01-14 10:23:35 -08:00
parent 953c2f1522
commit 0d8653894a
19 changed files with 499 additions and 320 deletions

View file

@ -3,15 +3,15 @@
use crate::{File, Position, Rank, Square};
use std::{fmt, fmt::Write};
pub struct DiagramFormatter<'a>(&'a Position);
pub struct DiagramFormatter<'a, PosC>(&'a Position<PosC>);
impl<'a> DiagramFormatter<'a> {
pub fn new(position: &'a Position) -> DiagramFormatter {
impl<'a, PosC> DiagramFormatter<'a, PosC> {
pub fn new(position: &'a Position<PosC>) -> DiagramFormatter<PosC> {
DiagramFormatter(position)
}
}
impl<'a> fmt::Display for DiagramFormatter<'a> {
impl<'a, PosC> fmt::Display for DiagramFormatter<'a, PosC> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut output = String::new();