[board] Clean up the formatting of BitBoards
Use debug_tuple in the fmt::Debug implementation. Implement fmt::Binary, fmt::UpperHex, and fmt::LowerHex by delegating to u64's version.
This commit is contained in:
parent
41421dddbb
commit
808222eef1
1 changed files with 24 additions and 2 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue