mirror of
https://github.com/BurntSushi/jiff.git
synced 2025-12-23 08:47:45 +00:00
fmt: slight simplification
This lets me un-export `Decimal::new`. A small matter.
This commit is contained in:
parent
00e630b76f
commit
729374ba20
2 changed files with 4 additions and 7 deletions
|
|
@ -399,7 +399,7 @@ trait WriteExt: Write {
|
|||
formatter: &DecimalFormatter,
|
||||
n: impl Into<i64>,
|
||||
) -> Result<(), Error> {
|
||||
self.write_decimal(&Decimal::new(formatter, n.into()))
|
||||
self.write_decimal(&formatter.format(n.into()))
|
||||
}
|
||||
|
||||
/// Write the given fractional number using ASCII digits to this buffer.
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ impl DecimalFormatter {
|
|||
|
||||
/// Format the given value using this configuration as a decimal ASCII
|
||||
/// number.
|
||||
#[cfg(test)]
|
||||
#[cfg_attr(feature = "perf-inline", inline(always))]
|
||||
pub(crate) const fn format(&self, value: i64) -> Decimal {
|
||||
Decimal::new(self, value)
|
||||
}
|
||||
|
|
@ -97,10 +97,7 @@ impl Decimal {
|
|||
/// Using the given formatter, turn the value given into a decimal
|
||||
/// representation using ASCII bytes.
|
||||
#[cfg_attr(feature = "perf-inline", inline(always))]
|
||||
pub(crate) const fn new(
|
||||
formatter: &DecimalFormatter,
|
||||
mut value: i64,
|
||||
) -> Decimal {
|
||||
const fn new(formatter: &DecimalFormatter, mut value: i64) -> Decimal {
|
||||
// Specialize the common case to generate tighter codegen.
|
||||
if value >= 0 && formatter.force_sign.is_none() {
|
||||
let mut decimal = Decimal {
|
||||
|
|
@ -180,7 +177,7 @@ impl Decimal {
|
|||
///
|
||||
/// The slice returned is guaranteed to be valid ASCII.
|
||||
#[inline]
|
||||
pub(crate) fn as_bytes(&self) -> &[u8] {
|
||||
fn as_bytes(&self) -> &[u8] {
|
||||
&self.buf[usize::from(self.start)..usize::from(self.end)]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue