diff --git a/board/src/bitboard/bitboard.rs b/board/src/bitboard/bitboard.rs index 113b53c..746ad6f 100644 --- a/board/src/bitboard/bitboard.rs +++ b/board/src/bitboard/bitboard.rs @@ -47,10 +47,32 @@ impl BitBoard { } } +impl fmt::Binary for BitBoard { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Delegate to u64's implementation of Binary. + fmt::Binary::fmt(&self.0, f) + } +} + +impl fmt::LowerHex for BitBoard { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Delegate to u64's implementation of LowerHex. + fmt::LowerHex::fmt(&self.0, f) + } +} + +impl fmt::UpperHex for BitBoard { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Delegate to u64's implementation of UpperHex. + fmt::UpperHex::fmt(&self.0, f) + } +} + impl fmt::Debug for BitBoard { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - let bits = self.0; - write!(f, "BitBoard({bits:064b})") + f.debug_tuple("BitBoard") + .field(&format_args!("{:064b}", self.0)) + .finish() } }