Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #316 from dtolnay/displaynum
Browse files Browse the repository at this point in the history
Make Display for Number produce the same representation as serializing
  • Loading branch information
dtolnay committed Aug 21, 2022
2 parents 3ef5ebb + e437e98 commit c162706
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/number.rs
Expand Up @@ -293,8 +293,8 @@ impl Number {
impl Display for Number {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
match self.n {
N::PosInt(i) => Display::fmt(&i, formatter),
N::NegInt(i) => Display::fmt(&i, formatter),
N::PosInt(i) => formatter.write_str(itoa::Buffer::new().format(i)),
N::NegInt(i) => formatter.write_str(itoa::Buffer::new().format(i)),
N::Float(f) if f.is_nan() => formatter.write_str(".nan"),
N::Float(f) if f.is_infinite() => {
if f.is_sign_negative() {
Expand All @@ -303,7 +303,7 @@ impl Display for Number {
formatter.write_str(".inf")
}
}
N::Float(f) => Display::fmt(&f, formatter),
N::Float(f) => formatter.write_str(ryu::Buffer::new().format_finite(f)),
}
}
}
Expand Down

0 comments on commit c162706

Please sign in to comment.