/// A type that describes a format. /// /// Implementors of [`Formattable`] are [format descriptions](crate::format_description). /// /// [`Date::format`] and [`Time::format`] each use a format description to generate /// a String from their data. See the respective methods for usage examples. #[cfg_attr(__time_03_docs, doc(notable_trait))] pubtrait Formattable: sealed::Sealed {} impl Formattable for BorrowedFormatItem<'_> {} impl Formattable for [BorrowedFormatItem<'_>] {} impl Formattable for OwnedFormatItem {} impl Formattable for [OwnedFormatItem] {} impl Formattable for Rfc3339 {} impl Formattable for Rfc2822 {} impl<const CONFIG: EncodedConfig> Formattable for Iso8601<CONFIG> {} impl<T: Deref> Formattable for T where T::Target: Formattable {}
/// Seal the trait to prevent downstream users from implementing it. mod sealed { #[allow(clippy::wildcard_imports)] usesuper::*;
/// Format the item using a format description, the intended output, and the various components. pubtrait Sealed { /// Format the item into the provided output, returning the number of bytes written. fn format_into(
&self,
output: &mutimpl io::Write,
date: Option<Date>,
time: Option<Time>,
offset: Option<UtcOffset>,
) -> Result<usize, error::Format>;
/// Format the item directly to a `String`. fn format(
&self,
date: Option<Date>,
time: Option<Time>,
offset: Option<UtcOffset>,
) -> Result<String, error::Format> { letmut buf = Vec::new(); self.format_into(&mut buf, date, time, offset)?;
Ok(String::from_utf8_lossy(&buf).into_owned())
}
}
}
ifSelf::FORMAT_DATE { let date = date.ok_or(error::Format::InsufficientTypeInformation)?;
bytes += iso8601::format_date::<CONFIG>(output, date)?;
} ifSelf::FORMAT_TIME { let time = time.ok_or(error::Format::InsufficientTypeInformation)?;
bytes += iso8601::format_time::<CONFIG>(output, time)?;
} ifSelf::FORMAT_OFFSET { let offset = offset.ok_or(error::Format::InsufficientTypeInformation)?;
bytes += iso8601::format_offset::<CONFIG>(output, offset)?;
}
if bytes == 0 { // The only reason there would be no bytes written is if the format was only for // parsing.
panic!("attempted to format a parsing-only format description");
}
Ok(bytes)
}
} // endregion well-known formats
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.