From fa86d270b9294d50621c59267a88ad6afad839be Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Tue, 25 Jul 2023 07:54:43 +0200 Subject: [PATCH] Make `write_rfc3339` available in `no_std` --- src/format/formatting.rs | 16 ++++++---------- src/format/mod.rs | 5 +++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/format/formatting.rs b/src/format/formatting.rs index c0a877cd09..429b9658b0 100644 --- a/src/format/formatting.rs +++ b/src/format/formatting.rs @@ -10,19 +10,17 @@ use core::borrow::Borrow; use core::fmt; use core::fmt::Write; +use crate::datetime::SecondsFormat; #[cfg(any(feature = "alloc", feature = "std"))] -use crate::naive::{NaiveDate, NaiveDateTime, NaiveTime}; +use crate::offset::Offset; +use crate::{Datelike, FixedOffset, NaiveDateTime, Timelike}; #[cfg(any(feature = "alloc", feature = "std"))] -use crate::offset::{FixedOffset, Offset}; -#[cfg(any(feature = "alloc", feature = "std"))] -use crate::{Datelike, SecondsFormat, Timelike, Weekday}; +use crate::{NaiveDate, NaiveTime, Weekday}; use super::locales; +use super::{Colons, OffsetFormat, OffsetPrecision, Pad}; #[cfg(any(feature = "alloc", feature = "std"))] -use super::{ - Colons, Fixed, InternalFixed, InternalInternal, Item, Locale, Numeric, OffsetFormat, - OffsetPrecision, Pad, -}; +use super::{Fixed, InternalFixed, InternalInternal, Item, Locale, Numeric}; use locales::*; /// A *temporary* object which can be used as an argument to `format!` or others. @@ -447,7 +445,6 @@ fn format_inner( } } -#[cfg(any(feature = "alloc", feature = "std"))] impl OffsetFormat { /// Writes an offset from UTC with the format defined by `self`. fn format(&self, w: &mut impl Write, off: FixedOffset) -> fmt::Result { @@ -528,7 +525,6 @@ impl OffsetFormat { } /// Writes the date, time and offset to the string. same as `%Y-%m-%dT%H:%M:%S%.f%:z` -#[cfg(any(feature = "alloc", feature = "std"))] #[inline] pub(crate) fn write_rfc3339( w: &mut impl Write, diff --git a/src/format/mod.rs b/src/format/mod.rs index 65598187e6..42ee3c2fb2 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -52,11 +52,12 @@ pub(crate) mod locales; pub(crate) use formatting::write_hundreds; #[cfg(any(feature = "alloc", feature = "std"))] +pub(crate) use formatting::write_rfc2822; +pub(crate) use formatting::write_rfc3339; +#[cfg(any(feature = "alloc", feature = "std"))] pub use formatting::{format, format_item, DelayedFormat}; #[cfg(feature = "unstable-locales")] pub use formatting::{format_item_localized, format_localized}; -#[cfg(any(feature = "alloc", feature = "std"))] -pub(crate) use formatting::{write_rfc2822, write_rfc3339}; #[cfg(feature = "unstable-locales")] pub use locales::Locale; #[cfg(not(feature = "unstable-locales"))]