Inline format_inner

This commit is contained in:
Paul Dicker 2023-10-01 13:57:37 +02:00 committed by Paul Dicker
parent 4947c90046
commit cc0139996f

View File

@ -120,14 +120,18 @@ impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> DelayedFormat<I> {
let locale = None; let locale = None;
for item in self.items.clone() { for item in self.items.clone() {
format_inner( match *item.borrow() {
w, Item::Literal(s) | Item::Space(s) => w.write_str(s),
self.date, #[cfg(feature = "alloc")]
self.time, Item::OwnedLiteral(ref s) | Item::OwnedSpace(ref s) => w.write_str(s),
self.off.as_ref(), Item::Numeric(ref spec, ref pad) => {
item.borrow(), format_numeric(w, self.date, self.time, self.off.as_ref(), spec, pad)
locale, }
)?; Item::Fixed(ref spec) => {
format_fixed(w, self.date, self.time, self.off.as_ref(), spec, locale)
}
Item::Error => Err(fmt::Error),
}?;
} }
Ok(()) Ok(())
} }
@ -189,25 +193,6 @@ pub fn format_item(
.fmt(w) .fmt(w)
} }
#[cfg(feature = "alloc")]
fn format_inner(
w: &mut impl Write,
date: Option<NaiveDate>,
time: Option<NaiveTime>,
off: Option<&(String, FixedOffset)>,
item: &Item<'_>,
locale: Option<Locale>,
) -> fmt::Result {
match *item {
Item::Literal(s) | Item::Space(s) => w.write_str(s),
#[cfg(feature = "alloc")]
Item::OwnedLiteral(ref s) | Item::OwnedSpace(ref s) => w.write_str(s),
Item::Numeric(ref spec, ref pad) => format_numeric(w, date, time, off, spec, pad),
Item::Fixed(ref spec) => format_fixed(w, date, time, off, spec, locale),
Item::Error => Err(fmt::Error),
}
}
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
fn format_numeric( fn format_numeric(
w: &mut impl Write, w: &mut impl Write,