fmt: slight simplification

This lets me un-export `Decimal::new`. A small matter.
This commit is contained in:
Andrew Gallant 2025-11-01 14:35:19 -04:00
parent 00e630b76f
commit 729374ba20
2 changed files with 4 additions and 7 deletions

View file

@ -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.

View file

@ -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)]
}