dtolnay / ryu

Fast floating point to string conversion
Apache License 2.0
606 stars 27 forks source link

A Display implementation? #23

Closed droundy closed 4 years ago

droundy commented 4 years ago

I'm missing in this crate a Display implementation so that it could be easy to use when formatting numbers. Ideally this would also allow for reducing precision and other formatting flags.

dtolnay commented 4 years ago

Closing because I would prefer not to expose customization of the precision and other flags in this library. The algorithm should generalize to this though, so someone could make a fork with this functionality.

For implementing a Display impl based on ryu's formatting, the following would work:

let mut buffer = ryu::Buffer::new();
formatter.write_str(buffer.format(1.234))?;