Skip to content

Commit

Permalink
fix formatting for arrays after #156
Browse files Browse the repository at this point in the history
arrays shouldn't be formatted with a leading reference
  • Loading branch information
abonander committed Jul 5, 2019
1 parent 56ff009 commit 40c1476
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions phf_shared/src/lib.rs
Expand Up @@ -212,6 +212,11 @@ impl PhfHash for char {
}
}

// minimize duplicated code since formatting drags in quite a bit
fn fmt_array(array: &[u8], f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", array)
}

macro_rules! array_impl(
($t:ty, $n:expr) => (
impl PhfHash for [$t; $n] {
Expand All @@ -223,8 +228,7 @@ macro_rules! array_impl(

impl FmtConst for [$t; $n] {
fn fmt_const(&self, f: &mut fmt::Formatter) -> fmt::Result {
// delegate to the slice impl to minimize duplicated code
self[..].fmt_const(f)
fmt_array(self, f)
}
}
)
Expand Down

0 comments on commit 40c1476

Please sign in to comment.