Skip to content

Commit

Permalink
fix(bitfield): remove recursion in fmt::Binary (#292)
Browse files Browse the repository at this point in the history
Turns out this will recur infinitely, because it calls `self`'s
`fmt::Binary` impl instead of `self.0`'s (the actual integer value).
WHOOPS!
  • Loading branch information
hawkw committed Aug 8, 2022
1 parent 6be1d21 commit 0488696
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bitfield/src/bitfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ macro_rules! bitfield {
impl core::fmt::Binary for $Name {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
if f.alternate() {
f.debug_tuple(stringify!($Name)).field(&format_args!("{:#b}", self)).finish()
f.debug_tuple(stringify!($Name)).field(&format_args!("{:#b}", self.0)).finish()
} else {
f.debug_tuple(stringify!($Name)).field(&format_args!("{:b}", self)).finish()
f.debug_tuple(stringify!($Name)).field(&format_args!("{:b}", self.0)).finish()
}
}
}
Expand Down

0 comments on commit 0488696

Please sign in to comment.