Skip to content

Commit

Permalink
Correct feature gates
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Aug 12, 2023
1 parent 80238b5 commit a117e7e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/format/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,37 @@ use core::borrow::Borrow;
use core::fmt;
use core::fmt::Write;

#[cfg(any(
feature = "alloc",
feature = "std",
feature = "serde",
feature = "rustc-serialize"
))]
use crate::datetime::SecondsFormat;
#[cfg(any(feature = "alloc", feature = "std"))]
use crate::offset::Offset;
#[cfg(any(
feature = "alloc",
feature = "std",
feature = "serde",
feature = "rustc-serialize"
))]
use crate::{Datelike, FixedOffset, NaiveDateTime, Timelike};
#[cfg(any(feature = "alloc", feature = "std"))]
use crate::{NaiveDate, NaiveTime, Weekday};

#[cfg(any(feature = "alloc", feature = "std"))]
use super::locales;
#[cfg(any(
feature = "alloc",
feature = "std",
feature = "serde",
feature = "rustc-serialize"
))]
use super::{Colons, OffsetFormat, OffsetPrecision, Pad};
#[cfg(any(feature = "alloc", feature = "std"))]
use super::{Fixed, InternalFixed, InternalInternal, Item, Locale, Numeric};
#[cfg(any(feature = "alloc", feature = "std"))]
use locales::*;

/// A *temporary* object which can be used as an argument to `format!` or others.
Expand Down Expand Up @@ -445,6 +465,7 @@ fn format_inner(
}
}

#[cfg(any(feature = "alloc", feature = "std", feature = "serde", feature = "rustc-serialize"))]
impl OffsetFormat {
/// Writes an offset from UTC with the format defined by `self`.
fn format(&self, w: &mut impl Write, off: FixedOffset) -> fmt::Result {
Expand Down Expand Up @@ -526,6 +547,7 @@ impl OffsetFormat {

/// Writes the date, time and offset to the string. same as `%Y-%m-%dT%H:%M:%S%.f%:z`
#[inline]
#[cfg(any(feature = "alloc", feature = "std", feature = "serde", feature = "rustc-serialize"))]
pub(crate) fn write_rfc3339(
w: &mut impl Write,
dt: NaiveDateTime,
Expand Down
11 changes: 9 additions & 2 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,26 @@ pub(crate) mod scan;

pub mod strftime;

#[cfg(any(feature = "alloc", feature = "std"))]
pub(crate) mod locales;

pub(crate) use formatting::write_hundreds;
#[cfg(any(feature = "alloc", feature = "std"))]
pub(crate) use formatting::write_rfc2822;
#[cfg(any(
feature = "alloc",
feature = "std",
feature = "serde",
feature = "rustc-serialize"
))]
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(feature = "unstable-locales")]
#[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))]
pub use locales::Locale;
#[cfg(not(feature = "unstable-locales"))]
#[cfg(all(not(feature = "unstable-locales"), any(feature = "alloc", feature = "std")))]
pub(crate) use locales::Locale;
pub use parse::{parse, parse_and_remainder};
pub use parsed::Parsed;
Expand Down

0 comments on commit a117e7e

Please sign in to comment.