diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-02-26 19:43:29 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-02-26 19:43:29 +0300 |
commit | 280fbc2acedcc5bbfcca141e610b3b37cf7d4397 (patch) | |
tree | f34c22268036545f350682fc1c591f59ed76279f | |
parent | 3ae684ec1f697f2e34eec755bfeffb20a3a1d856 (diff) | |
download | chessnost-280fbc2acedcc5bbfcca141e610b3b37cf7d4397.tar.gz |
feat: implement notation Display for moves
-rw-r--r-- | src/moves.rs | 8 | ||||
-rw-r--r-- | src/square.rs | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/moves.rs b/src/moves.rs index 3cf9fd3..b8ced18 100644 --- a/src/moves.rs +++ b/src/moves.rs @@ -1,4 +1,4 @@ -use std::str::Chars; +use std::{str::Chars, fmt::Display}; use crate::{square::Square, bitboard::BitboardFns, board::piece::Piece}; @@ -36,3 +36,9 @@ impl Move { Move { source, target, kind: MoveKind::Quiet } } } + +impl Display for Move { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}{}", self.source, self.target) + } +} diff --git a/src/square.rs b/src/square.rs index 8a268ea..c7f185e 100644 --- a/src/square.rs +++ b/src/square.rs @@ -1,4 +1,4 @@ -use std::str::Chars; +use std::{str::Chars, fmt::Display}; use crate::bitboard::Bitboard; @@ -91,4 +91,11 @@ impl Square { } } +impl Display for Square { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let notation = format!("{:?}", self).to_lowercase(); + write!(f, "{}", notation) + } +} + |