aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-20 23:14:32 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-20 23:14:32 +0300
commit1b33595091334bb17db78298cad4eefa7b448c22 (patch)
tree68999b6a6a8696ffc63b1482a379c16678c432e3 /src
parent6a2fb1154c441ad680de29240f30fea62ce9661c (diff)
downloadchessnost-1b33595091334bb17db78298cad4eefa7b448c22.tar.gz
feat: implement Display for Bitboard
Diffstat (limited to 'src')
-rw-r--r--src/main.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index e7a11a9..822f773 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,22 @@
+use std::fmt;
+
+struct Bitboard(u64);
+
+impl fmt::Display for Bitboard {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ for index in (0..64) {
+ f.write_str(if (&self.0 >> index & 1 == 1) { "1" } else { "." });
+ if ((index + 1) % 8 == 0) {
+ f.write_str("\n");
+ }
+ }
+ return write!(f, "\n")
+ }
+}
+
fn main() {
+ const bb:Bitboard = Bitboard(33);
println!("Hello, world!");
+ println!("{}", bb);
+ println!("{}", bb.0);
}