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

Make Display for Number produce the same representation as serializing #316

Merged
merged 1 commit into from Aug 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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