pub(crate) struct DecimalFormatter {
force_sign: Option<bool>,
minimum_digits: u8,
padding_byte: u8,
}
Expand description
A simple formatter for converting i64
values to ASCII byte strings.
This avoids going through the formatting machinery which seems to substantially slow things down.
The itoa
crate does the same thing as this formatter, but is a bit
faster. We roll our own which is a bit slower, but gets us enough of a win
to be satisfied with and with (almost) pure safe code.
By default, this only includes the sign if it’s negative. To always include
the sign, set force_sign
to true
.
Fields§
§force_sign: Option<bool>
§minimum_digits: u8
§padding_byte: u8
Implementations§
Source§impl DecimalFormatter
impl DecimalFormatter
Sourcepub(crate) const fn new() -> DecimalFormatter
pub(crate) const fn new() -> DecimalFormatter
Creates a new decimal formatter using the default configuration.
Sourcepub(crate) const fn padding(self, digits: u8) -> DecimalFormatter
pub(crate) const fn padding(self, digits: u8) -> DecimalFormatter
The minimum number of digits/padding that this number should be formatted with. If the number would have fewer digits than this, then it is padded out with the padding byte (which is zero by default) until the minimum is reached.
The minimum number of digits is capped at the maximum number of digits for an i64 value (which is 19).
Sourcepub(crate) const fn padding_byte(self, byte: u8) -> DecimalFormatter
pub(crate) const fn padding_byte(self, byte: u8) -> DecimalFormatter
The padding byte to use when padding
is set.
The default is 0
.
Trait Implementations§
Source§impl Clone for DecimalFormatter
impl Clone for DecimalFormatter
Source§fn clone(&self) -> DecimalFormatter
fn clone(&self) -> DecimalFormatter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more