From 4d9976856415025d81546b1a2f4896c5fc994622 Mon Sep 17 00:00:00 2001 From: Dennis Orlando Date: Sat, 28 Sep 2024 10:40:58 +0200 Subject: [PATCH] cargo fmt w/ rustfmt 1.8.0-nightly --- time-macros/src/date.rs | 4 ++-- time-macros/src/datetime.rs | 2 +- time-macros/src/format_description/ast.rs | 2 +- .../src/format_description/format_item.rs | 2 +- time-macros/src/helpers/mod.rs | 2 +- time-macros/src/offset.rs | 4 ++-- time-macros/src/time.rs | 4 ++-- time/src/date.rs | 20 ++++++++----------- time/src/duration.rs | 6 +++--- time/src/ext/numerical_duration.rs | 2 +- time/src/format_description/parse/ast.rs | 2 +- .../format_description/parse/format_item.rs | 2 +- time/src/format_description/parse/lexer.rs | 2 +- time/src/formatting/formattable.rs | 4 ++-- time/src/formatting/iso8601.rs | 4 ++-- time/src/formatting/mod.rs | 4 ++-- time/src/instant.rs | 2 +- time/src/offset_date_time.rs | 2 +- time/src/parsing/combinator/mod.rs | 2 +- time/src/parsing/combinator/rfc/iso8601.rs | 4 ++-- time/src/parsing/combinator/rfc/rfc2822.rs | 2 +- time/src/parsing/component.rs | 4 ++-- time/src/parsing/iso8601.rs | 4 ++-- time/src/parsing/parsable.rs | 6 +++--- time/src/parsing/parsed.rs | 19 +++++++++--------- time/src/primitive_date_time.rs | 2 +- time/src/quickcheck.rs | 2 +- time/src/rand.rs | 2 +- time/src/serde/iso8601.rs | 8 ++++---- time/src/serde/mod.rs | 2 +- time/src/serde/rfc2822.rs | 6 +++--- time/src/serde/rfc3339.rs | 6 +++--- time/src/serde/timestamp/microseconds.rs | 2 +- time/src/serde/timestamp/milliseconds.rs | 2 +- time/src/serde/timestamp/mod.rs | 2 +- time/src/serde/timestamp/nanoseconds.rs | 2 +- time/src/serde/visitor.rs | 2 +- time/src/time.rs | 16 ++++++--------- time/src/utc_offset.rs | 6 +++--- 39 files changed, 82 insertions(+), 89 deletions(-) diff --git a/time-macros/src/date.rs b/time-macros/src/date.rs index 03cbf11ae2..e684a1845d 100644 --- a/time-macros/src/date.rs +++ b/time-macros/src/date.rs @@ -1,14 +1,14 @@ use std::iter::Peekable; use num_conv::Truncate; -use proc_macro::{token_stream, TokenTree}; +use proc_macro::{TokenTree, token_stream}; use time_core::util::{days_in_year, weeks_in_year}; +use crate::Error; use crate::helpers::{ consume_any_ident, consume_number, consume_punct, days_in_year_month, ymd_to_yo, ywd_to_yo, }; use crate::to_tokens::ToTokenTree; -use crate::Error; #[cfg(feature = "large-dates")] const MAX_YEAR: i32 = 999_999; diff --git a/time-macros/src/datetime.rs b/time-macros/src/datetime.rs index 2d41e9a532..c7d2bf6f7a 100644 --- a/time-macros/src/datetime.rs +++ b/time-macros/src/datetime.rs @@ -1,6 +1,6 @@ use std::iter::Peekable; -use proc_macro::{token_stream, Ident, Span, TokenTree}; +use proc_macro::{Ident, Span, TokenTree, token_stream}; use crate::date::Date; use crate::error::Error; diff --git a/time-macros/src/format_description/ast.rs b/time-macros/src/format_description/ast.rs index 4c3a19e5a6..664a7c4279 100644 --- a/time-macros/src/format_description/ast.rs +++ b/time-macros/src/format_description/ast.rs @@ -1,6 +1,6 @@ use std::iter; -use super::{lexer, unused, Error, Location, Spanned, SpannedValue, Unused}; +use super::{Error, Location, Spanned, SpannedValue, Unused, lexer, unused}; pub(super) enum Item<'a> { Literal(Spanned<&'a [u8]>), diff --git a/time-macros/src/format_description/format_item.rs b/time-macros/src/format_description/format_item.rs index e6f8e67ae7..af54a7da69 100644 --- a/time-macros/src/format_description/format_item.rs +++ b/time-macros/src/format_description/format_item.rs @@ -1,7 +1,7 @@ use std::num::NonZeroU16; use std::str::{self, FromStr}; -use super::{ast, unused, Error, Span, Spanned, Unused}; +use super::{Error, Span, Spanned, Unused, ast, unused}; pub(super) fn parse<'a>( ast_items: impl Iterator, Error>>, diff --git a/time-macros/src/helpers/mod.rs b/time-macros/src/helpers/mod.rs index 0cca2002de..532c8ae941 100644 --- a/time-macros/src/helpers/mod.rs +++ b/time-macros/src/helpers/mod.rs @@ -5,7 +5,7 @@ use std::iter::Peekable; use std::str::FromStr; use num_conv::prelude::*; -use proc_macro::{token_stream, Span, TokenTree}; +use proc_macro::{Span, TokenTree, token_stream}; use time_core::util::{days_in_year, is_leap_year}; use crate::Error; diff --git a/time-macros/src/offset.rs b/time-macros/src/offset.rs index 04dd37f131..732f69073c 100644 --- a/time-macros/src/offset.rs +++ b/time-macros/src/offset.rs @@ -1,12 +1,12 @@ use std::iter::Peekable; use num_conv::prelude::*; -use proc_macro::{token_stream, Span, TokenTree}; +use proc_macro::{Span, TokenTree, token_stream}; use time_core::convert::*; +use crate::Error; use crate::helpers::{consume_any_ident, consume_number, consume_punct}; use crate::to_tokens::ToTokenTree; -use crate::Error; pub(crate) struct Offset { pub(crate) hours: i8, diff --git a/time-macros/src/time.rs b/time-macros/src/time.rs index 4e565c1ded..e86a1bdd16 100644 --- a/time-macros/src/time.rs +++ b/time-macros/src/time.rs @@ -1,11 +1,11 @@ use std::iter::Peekable; -use proc_macro::{token_stream, Span, TokenTree}; +use proc_macro::{Span, TokenTree, token_stream}; use time_core::convert::*; +use crate::Error; use crate::helpers::{consume_any_ident, consume_number, consume_punct}; use crate::to_tokens::ToTokenTree; -use crate::Error; enum Period { Am, diff --git a/time/src/date.rs b/time/src/date.rs index ed443c5fd1..7a05a31596 100644 --- a/time/src/date.rs +++ b/time/src/date.rs @@ -25,7 +25,7 @@ use crate::internal_macros::{ #[cfg(feature = "parsing")] use crate::parsing::Parsable; use crate::util::{days_in_year, days_in_year_month, is_leap_year, weeks_in_year}; -use crate::{error, Duration, Month, PrimitiveDateTime, Time, Weekday}; +use crate::{Duration, Month, PrimitiveDateTime, Time, Weekday, error}; type Year = RangedI32; @@ -1376,17 +1376,13 @@ impl SmartDisplay for Date { day => width(2), ); - Metadata::new( - formatted_width, - self, - DateMetadata { - year_width, - display_sign, - year, - month: u8::from(month), - day, - }, - ) + Metadata::new(formatted_width, self, DateMetadata { + year_width, + display_sign, + year, + month: u8::from(month), + day, + }) } fn fmt_with_metadata( diff --git a/time/src/duration.rs b/time/src/duration.rs index b3d00566bd..fcf04acd5e 100644 --- a/time/src/duration.rs +++ b/time/src/duration.rs @@ -9,14 +9,14 @@ use core::time::Duration as StdDuration; use deranged::RangedI32; use num_conv::prelude::*; +#[cfg(feature = "std")] +#[allow(deprecated)] +use crate::Instant; use crate::convert::*; use crate::error; use crate::internal_macros::{ const_try_opt, expect_opt, impl_add_assign, impl_div_assign, impl_mul_assign, impl_sub_assign, }; -#[cfg(feature = "std")] -#[allow(deprecated)] -use crate::Instant; /// By explicitly inserting this enum where padding is expected, the compiler is able to better /// perform niche value optimization. diff --git a/time/src/ext/numerical_duration.rs b/time/src/ext/numerical_duration.rs index fb9209d235..24ab70e052 100644 --- a/time/src/ext/numerical_duration.rs +++ b/time/src/ext/numerical_duration.rs @@ -1,5 +1,5 @@ -use crate::convert::*; use crate::Duration; +use crate::convert::*; /// Sealed trait to prevent downstream implementations. mod sealed { diff --git a/time/src/format_description/parse/ast.rs b/time/src/format_description/parse/ast.rs index c7fc5e05a0..fa5612d4ee 100644 --- a/time/src/format_description/parse/ast.rs +++ b/time/src/format_description/parse/ast.rs @@ -5,7 +5,7 @@ use alloc::string::String; use alloc::vec::Vec; use core::iter; -use super::{lexer, unused, Error, Location, Spanned, SpannedValue, Unused}; +use super::{Error, Location, Spanned, SpannedValue, Unused, lexer, unused}; use crate::internal_macros::bug; /// One part of a complete format description. diff --git a/time/src/format_description/parse/format_item.rs b/time/src/format_description/parse/format_item.rs index fc2332d2f6..83050fefb6 100644 --- a/time/src/format_description/parse/format_item.rs +++ b/time/src/format_description/parse/format_item.rs @@ -5,7 +5,7 @@ use alloc::string::String; use core::num::NonZeroU16; use core::str::{self, FromStr}; -use super::{ast, unused, Error, Span, Spanned}; +use super::{Error, Span, Spanned, ast, unused}; use crate::internal_macros::bug; /// Parse an AST iterator into a sequence of format items. diff --git a/time/src/format_description/parse/lexer.rs b/time/src/format_description/parse/lexer.rs index 2979fff9ee..ada7f18277 100644 --- a/time/src/format_description/parse/lexer.rs +++ b/time/src/format_description/parse/lexer.rs @@ -2,7 +2,7 @@ use core::iter; -use super::{unused, Error, Location, Spanned, SpannedValue}; +use super::{Error, Location, Spanned, SpannedValue, unused}; /// An iterator over the lexed tokens. pub(super) struct Lexed { diff --git a/time/src/formatting/formattable.rs b/time/src/formatting/formattable.rs index 7cfa9301e9..4aed970b19 100644 --- a/time/src/formatting/formattable.rs +++ b/time/src/formatting/formattable.rs @@ -11,9 +11,9 @@ use crate::format_description::well_known::iso8601::EncodedConfig; use crate::format_description::well_known::{Iso8601, Rfc2822, Rfc3339}; use crate::format_description::{BorrowedFormatItem, OwnedFormatItem}; use crate::formatting::{ - format_component, format_number_pad_zero, iso8601, write, MONTH_NAMES, WEEKDAY_NAMES, + MONTH_NAMES, WEEKDAY_NAMES, format_component, format_number_pad_zero, iso8601, write, }; -use crate::{error, Date, Time, UtcOffset}; +use crate::{Date, Time, UtcOffset, error}; /// A type that describes a format. /// diff --git a/time/src/formatting/iso8601.rs b/time/src/formatting/iso8601.rs index ee49d7d896..a0cd660ae2 100644 --- a/time/src/formatting/iso8601.rs +++ b/time/src/formatting/iso8601.rs @@ -5,12 +5,12 @@ use std::io; use num_conv::prelude::*; use crate::convert::*; +use crate::format_description::well_known::Iso8601; use crate::format_description::well_known::iso8601::{ DateKind, EncodedConfig, OffsetPrecision, TimePrecision, }; -use crate::format_description::well_known::Iso8601; use crate::formatting::{format_float, format_number_pad_zero, write, write_if, write_if_else}; -use crate::{error, Date, Time, UtcOffset}; +use crate::{Date, Time, UtcOffset, error}; /// Format the date portion of ISO 8601. pub(super) fn format_date( diff --git a/time/src/formatting/mod.rs b/time/src/formatting/mod.rs index 767cbe8721..7f4107f23d 100644 --- a/time/src/formatting/mod.rs +++ b/time/src/formatting/mod.rs @@ -11,8 +11,8 @@ use num_conv::prelude::*; pub use self::formattable::Formattable; use crate::convert::*; use crate::ext::DigitCount; -use crate::format_description::{modifier, Component}; -use crate::{error, Date, OffsetDateTime, Time, UtcOffset}; +use crate::format_description::{Component, modifier}; +use crate::{Date, OffsetDateTime, Time, UtcOffset, error}; #[allow(clippy::missing_docs_in_private_items)] const MONTH_NAMES: [&[u8]; 12] = [ diff --git a/time/src/instant.rs b/time/src/instant.rs index 9f71070aa3..cf43062060 100644 --- a/time/src/instant.rs +++ b/time/src/instant.rs @@ -8,8 +8,8 @@ use core::ops::{Add, Sub}; use core::time::Duration as StdDuration; use std::time::Instant as StdInstant; -use crate::internal_macros::{impl_add_assign, impl_sub_assign}; use crate::Duration; +use crate::internal_macros::{impl_add_assign, impl_sub_assign}; /// A measurement of a monotonically non-decreasing clock. Opaque and useful only with [`Duration`]. /// diff --git a/time/src/offset_date_time.rs b/time/src/offset_date_time.rs index 52f1799851..4a7868f54e 100644 --- a/time/src/offset_date_time.rs +++ b/time/src/offset_date_time.rs @@ -26,7 +26,7 @@ use crate::internal_macros::{ }; #[cfg(feature = "parsing")] use crate::parsing::Parsable; -use crate::{error, util, Date, Duration, Month, PrimitiveDateTime, Time, UtcOffset, Weekday}; +use crate::{Date, Duration, Month, PrimitiveDateTime, Time, UtcOffset, Weekday, error, util}; /// The Julian day of the Unix epoch. // Safety: `ordinal` is not zero. diff --git a/time/src/parsing/combinator/mod.rs b/time/src/parsing/combinator/mod.rs index e3e1df76cb..d0f23ed08a 100644 --- a/time/src/parsing/combinator/mod.rs +++ b/time/src/parsing/combinator/mod.rs @@ -5,8 +5,8 @@ pub(crate) mod rfc; use num_conv::prelude::*; use crate::format_description::modifier::Padding; -use crate::parsing::shim::{Integer, IntegerParseBytes}; use crate::parsing::ParsedItem; +use crate::parsing::shim::{Integer, IntegerParseBytes}; /// Parse a "+" or "-" sign. Returns the ASCII byte representing the sign, if present. pub(crate) const fn sign(input: &[u8]) -> Option> { diff --git a/time/src/parsing/combinator/rfc/iso8601.rs b/time/src/parsing/combinator/rfc/iso8601.rs index 91eea2dc25..ff3e021827 100644 --- a/time/src/parsing/combinator/rfc/iso8601.rs +++ b/time/src/parsing/combinator/rfc/iso8601.rs @@ -2,12 +2,12 @@ //! //! [ISO 8601]: https://www.iso.org/iso-8601-date-and-time-format.html -use core::num::{NonZeroU16, NonZeroU8}; +use core::num::{NonZeroU8, NonZeroU16}; use num_conv::prelude::*; -use crate::parsing::combinator::{any_digit, ascii_char, exactly_n_digits, first_match, sign}; use crate::parsing::ParsedItem; +use crate::parsing::combinator::{any_digit, ascii_char, exactly_n_digits, first_match, sign}; use crate::{Month, Weekday}; /// What kind of format is being parsed. This is used to ensure each part of the format (date, time, diff --git a/time/src/parsing/combinator/rfc/rfc2822.rs b/time/src/parsing/combinator/rfc/rfc2822.rs index 8410de06e3..3591a182a0 100644 --- a/time/src/parsing/combinator/rfc/rfc2822.rs +++ b/time/src/parsing/combinator/rfc/rfc2822.rs @@ -2,9 +2,9 @@ //! //! [RFC 2822]: https://datatracker.ietf.org/doc/html/rfc2822 +use crate::parsing::ParsedItem; use crate::parsing::combinator::rfc::rfc2234::wsp; use crate::parsing::combinator::{ascii_char, one_or_more, zero_or_more}; -use crate::parsing::ParsedItem; /// Consume the `fws` rule. // The full rule is equivalent to /\r\n[ \t]+|[ \t]+(?:\r\n[ \t]+)*/ diff --git a/time/src/parsing/component.rs b/time/src/parsing/component.rs index fbaa896b2b..4f1f53cea0 100644 --- a/time/src/parsing/component.rs +++ b/time/src/parsing/component.rs @@ -1,17 +1,17 @@ //! Parsing implementations for all [`Component`](crate::format_description::Component)s. -use core::num::{NonZeroU16, NonZeroU8}; +use core::num::{NonZeroU8, NonZeroU16}; use num_conv::prelude::*; use crate::convert::*; use crate::format_description::modifier; +use crate::parsing::ParsedItem; #[cfg(feature = "large-dates")] use crate::parsing::combinator::n_to_m_digits_padded; use crate::parsing::combinator::{ any_digit, exactly_n_digits, exactly_n_digits_padded, first_match, n_to_m_digits, opt, sign, }; -use crate::parsing::ParsedItem; use crate::{Month, Weekday}; // region: date components diff --git a/time/src/parsing/iso8601.rs b/time/src/parsing/iso8601.rs index 000835b0dd..16a17aa039 100644 --- a/time/src/parsing/iso8601.rs +++ b/time/src/parsing/iso8601.rs @@ -5,10 +5,10 @@ use num_conv::prelude::*; use crate::convert::*; use crate::error; use crate::error::ParseFromDescription::{InvalidComponent, InvalidLiteral}; -use crate::format_description::well_known::iso8601::EncodedConfig; use crate::format_description::well_known::Iso8601; +use crate::format_description::well_known::iso8601::EncodedConfig; use crate::parsing::combinator::rfc::iso8601::{ - day, dayk, dayo, float, hour, min, month, week, year, ExtendedKind, + ExtendedKind, day, dayk, dayo, float, hour, min, month, week, year, }; use crate::parsing::combinator::{ascii_char, sign}; use crate::parsing::{Parsed, ParsedItem}; diff --git a/time/src/parsing/parsable.rs b/time/src/parsing/parsable.rs index 8386d132f4..b7d549ec72 100644 --- a/time/src/parsing/parsable.rs +++ b/time/src/parsing/parsable.rs @@ -5,14 +5,14 @@ use core::ops::Deref; use num_conv::prelude::*; use crate::error::TryFromParsed; -use crate::format_description::well_known::iso8601::EncodedConfig; -use crate::format_description::well_known::{Iso8601, Rfc2822, Rfc3339}; use crate::format_description::BorrowedFormatItem; #[cfg(feature = "alloc")] use crate::format_description::OwnedFormatItem; +use crate::format_description::well_known::iso8601::EncodedConfig; +use crate::format_description::well_known::{Iso8601, Rfc2822, Rfc3339}; use crate::internal_macros::bug; use crate::parsing::{Parsed, ParsedItem}; -use crate::{error, Date, Month, OffsetDateTime, Time, UtcOffset, Weekday}; +use crate::{Date, Month, OffsetDateTime, Time, UtcOffset, Weekday, error}; /// A type that can be parsed. #[cfg_attr(docsrs, doc(notable_trait))] diff --git a/time/src/parsing/parsed.rs b/time/src/parsing/parsed.rs index be46b3be60..30ebf0f9c7 100644 --- a/time/src/parsing/parsed.rs +++ b/time/src/parsing/parsed.rs @@ -1,10 +1,10 @@ //! Information parsed from an input and format description. -use core::num::{NonZeroU16, NonZeroU8}; +use core::num::{NonZeroU8, NonZeroU16}; use deranged::{ - OptionRangedI128, OptionRangedI32, OptionRangedI8, OptionRangedU16, OptionRangedU32, - OptionRangedU8, RangedI128, RangedI32, RangedI8, RangedU16, RangedU32, RangedU8, + OptionRangedI8, OptionRangedI32, OptionRangedI128, OptionRangedU8, OptionRangedU16, + OptionRangedU32, RangedI8, RangedI32, RangedI128, RangedU8, RangedU16, RangedU32, }; use num_conv::prelude::*; use num_conv::{CastUnsigned, Truncate}; @@ -14,15 +14,16 @@ use crate::date::{MAX_YEAR, MIN_YEAR}; use crate::error::TryFromParsed::InsufficientInformation; #[cfg(feature = "alloc")] use crate::format_description::OwnedFormatItem; -use crate::format_description::{modifier, BorrowedFormatItem, Component}; +use crate::format_description::{BorrowedFormatItem, Component, modifier}; use crate::internal_macros::{bug, const_try_opt}; +use crate::parsing::ParsedItem; use crate::parsing::component::{ - parse_day, parse_end, parse_hour, parse_ignore, parse_minute, parse_month, parse_offset_hour, - parse_offset_minute, parse_offset_second, parse_ordinal, parse_period, parse_second, - parse_subsecond, parse_unix_timestamp, parse_week_number, parse_weekday, parse_year, Period, + Period, parse_day, parse_end, parse_hour, parse_ignore, parse_minute, parse_month, + parse_offset_hour, parse_offset_minute, parse_offset_second, parse_ordinal, parse_period, + parse_second, parse_subsecond, parse_unix_timestamp, parse_week_number, parse_weekday, + parse_year, }; -use crate::parsing::ParsedItem; -use crate::{error, Date, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday}; +use crate::{Date, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday, error}; /// Sealed to prevent downstream implementations. mod sealed { diff --git a/time/src/primitive_date_time.rs b/time/src/primitive_date_time.rs index 85ae075e80..cd5d82b224 100644 --- a/time/src/primitive_date_time.rs +++ b/time/src/primitive_date_time.rs @@ -16,7 +16,7 @@ use crate::formatting::Formattable; use crate::internal_macros::{const_try, const_try_opt}; #[cfg(feature = "parsing")] use crate::parsing::Parsable; -use crate::{error, util, Date, Duration, Month, OffsetDateTime, Time, UtcOffset, Weekday}; +use crate::{Date, Duration, Month, OffsetDateTime, Time, UtcOffset, Weekday, error, util}; /// Combined date and time. #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/time/src/quickcheck.rs b/time/src/quickcheck.rs index 312a09e196..0fc27ba6f0 100644 --- a/time/src/quickcheck.rs +++ b/time/src/quickcheck.rs @@ -36,7 +36,7 @@ use alloc::boxed::Box; -use quickcheck::{empty_shrinker, single_shrinker, Arbitrary, Gen}; +use quickcheck::{Arbitrary, Gen, empty_shrinker, single_shrinker}; use crate::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday}; diff --git a/time/src/rand.rs b/time/src/rand.rs index 7f7627b979..fae66f667e 100644 --- a/time/src/rand.rs +++ b/time/src/rand.rs @@ -1,7 +1,7 @@ //! Implementation of [`Distribution`] for various structs. -use rand::distributions::{Distribution, Standard}; use rand::Rng; +use rand::distributions::{Distribution, Standard}; use crate::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday}; diff --git a/time/src/serde/iso8601.rs b/time/src/serde/iso8601.rs index f9e8a20f1e..dafe6a9d02 100644 --- a/time/src/serde/iso8601.rs +++ b/time/src/serde/iso8601.rs @@ -8,18 +8,18 @@ #[cfg(feature = "parsing")] use core::marker::PhantomData; -#[cfg(feature = "formatting")] -use serde::ser::Error as _; #[cfg(feature = "parsing")] use serde::Deserializer; #[cfg(feature = "formatting")] +use serde::ser::Error as _; +#[cfg(feature = "formatting")] use serde::{Serialize, Serializer}; #[cfg(feature = "parsing")] use super::Visitor; -use crate::format_description::well_known::iso8601::{Config, EncodedConfig}; -use crate::format_description::well_known::Iso8601; use crate::OffsetDateTime; +use crate::format_description::well_known::Iso8601; +use crate::format_description::well_known::iso8601::{Config, EncodedConfig}; /// The configuration of ISO 8601 used for serde implementations. pub(crate) const SERDE_CONFIG: EncodedConfig = diff --git a/time/src/serde/mod.rs b/time/src/serde/mod.rs index 5cc5122c99..05aff90231 100644 --- a/time/src/serde/mod.rs +++ b/time/src/serde/mod.rs @@ -210,7 +210,7 @@ pub use time_macros::serde_format_description as format_description; use self::visitor::Visitor; #[cfg(feature = "parsing")] -use crate::format_description::{modifier, BorrowedFormatItem, Component}; +use crate::format_description::{BorrowedFormatItem, Component, modifier}; use crate::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday}; // region: Date diff --git a/time/src/serde/rfc2822.rs b/time/src/serde/rfc2822.rs index eca90f5204..608abf7b78 100644 --- a/time/src/serde/rfc2822.rs +++ b/time/src/serde/rfc2822.rs @@ -8,17 +8,17 @@ #[cfg(feature = "parsing")] use core::marker::PhantomData; -#[cfg(feature = "formatting")] -use serde::ser::Error as _; #[cfg(feature = "parsing")] use serde::Deserializer; #[cfg(feature = "formatting")] +use serde::ser::Error as _; +#[cfg(feature = "formatting")] use serde::{Serialize, Serializer}; #[cfg(feature = "parsing")] use super::Visitor; -use crate::format_description::well_known::Rfc2822; use crate::OffsetDateTime; +use crate::format_description::well_known::Rfc2822; /// Serialize an [`OffsetDateTime`] using the well-known RFC2822 format. #[cfg(feature = "formatting")] diff --git a/time/src/serde/rfc3339.rs b/time/src/serde/rfc3339.rs index b1ffb25130..93fef80f9b 100644 --- a/time/src/serde/rfc3339.rs +++ b/time/src/serde/rfc3339.rs @@ -8,17 +8,17 @@ #[cfg(feature = "parsing")] use core::marker::PhantomData; -#[cfg(feature = "formatting")] -use serde::ser::Error as _; #[cfg(feature = "parsing")] use serde::Deserializer; #[cfg(feature = "formatting")] +use serde::ser::Error as _; +#[cfg(feature = "formatting")] use serde::{Serialize, Serializer}; #[cfg(feature = "parsing")] use super::Visitor; -use crate::format_description::well_known::Rfc3339; use crate::OffsetDateTime; +use crate::format_description::well_known::Rfc3339; /// Serialize an [`OffsetDateTime`] using the well-known RFC3339 format. #[cfg(feature = "formatting")] diff --git a/time/src/serde/timestamp/microseconds.rs b/time/src/serde/timestamp/microseconds.rs index 65c603ec35..7fd44bc1e3 100644 --- a/time/src/serde/timestamp/microseconds.rs +++ b/time/src/serde/timestamp/microseconds.rs @@ -8,7 +8,7 @@ //! [Unix timestamp]: https://en.wikipedia.org/wiki/Unix_time //! [with]: https://serde.rs/field-attrs.html#with -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use crate::OffsetDateTime; diff --git a/time/src/serde/timestamp/milliseconds.rs b/time/src/serde/timestamp/milliseconds.rs index e571b6c9e2..99c3470ab7 100644 --- a/time/src/serde/timestamp/milliseconds.rs +++ b/time/src/serde/timestamp/milliseconds.rs @@ -8,7 +8,7 @@ //! [Unix timestamp]: https://en.wikipedia.org/wiki/Unix_time //! [with]: https://serde.rs/field-attrs.html#with -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use crate::OffsetDateTime; diff --git a/time/src/serde/timestamp/mod.rs b/time/src/serde/timestamp/mod.rs index 6dd0db03cd..db1fb90f92 100644 --- a/time/src/serde/timestamp/mod.rs +++ b/time/src/serde/timestamp/mod.rs @@ -11,7 +11,7 @@ pub mod microseconds; pub mod milliseconds; pub mod nanoseconds; -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use crate::OffsetDateTime; diff --git a/time/src/serde/timestamp/nanoseconds.rs b/time/src/serde/timestamp/nanoseconds.rs index c71d1e7cdb..514dd2d42a 100644 --- a/time/src/serde/timestamp/nanoseconds.rs +++ b/time/src/serde/timestamp/nanoseconds.rs @@ -8,7 +8,7 @@ //! [Unix timestamp]: https://en.wikipedia.org/wiki/Unix_time //! [with]: https://serde.rs/field-attrs.html#with -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use crate::OffsetDateTime; diff --git a/time/src/serde/visitor.rs b/time/src/serde/visitor.rs index 3a4311ecb2..b6fc8c66bf 100644 --- a/time/src/serde/visitor.rs +++ b/time/src/serde/visitor.rs @@ -3,9 +3,9 @@ use core::fmt; use core::marker::PhantomData; -use serde::de; #[cfg(feature = "parsing")] use serde::Deserializer; +use serde::de; #[cfg(feature = "parsing")] use super::{ diff --git a/time/src/time.rs b/time/src/time.rs index 2bd2fefe8e..b269cf3a99 100644 --- a/time/src/time.rs +++ b/time/src/time.rs @@ -8,7 +8,7 @@ use core::time::Duration as StdDuration; #[cfg(feature = "formatting")] use std::io; -use deranged::{RangedU32, RangedU8}; +use deranged::{RangedU8, RangedU32}; use num_conv::prelude::*; use powerfmt::ext::FormatterExt; use powerfmt::smart_display::{self, FormatterOptions, Metadata, SmartDisplay}; @@ -20,7 +20,7 @@ use crate::internal_macros::{cascade, ensure_ranged, impl_add_assign, impl_sub_a #[cfg(feature = "parsing")] use crate::parsing::Parsable; use crate::util::DateAdjustment; -use crate::{error, Duration}; +use crate::{Duration, error}; /// By explicitly inserting this enum where padding is expected, the compiler is able to better /// perform niche value optimization. @@ -796,14 +796,10 @@ impl SmartDisplay for Time { ".", ) + subsecond_width; - Metadata::new( - formatted_width, - self, - TimeMetadata { - subsecond_width: subsecond_width.truncate(), - subsecond_value, - }, - ) + Metadata::new(formatted_width, self, TimeMetadata { + subsecond_width: subsecond_width.truncate(), + subsecond_value, + }) } fn fmt_with_metadata( diff --git a/time/src/utc_offset.rs b/time/src/utc_offset.rs index 7cf24d141c..ab2cdc5ebb 100644 --- a/time/src/utc_offset.rs +++ b/time/src/utc_offset.rs @@ -7,10 +7,12 @@ use core::ops::Neg; #[cfg(feature = "formatting")] use std::io; -use deranged::{RangedI32, RangedI8}; +use deranged::{RangedI8, RangedI32}; use powerfmt::ext::FormatterExt; use powerfmt::smart_display::{self, FormatterOptions, Metadata, SmartDisplay}; +#[cfg(feature = "local-offset")] +use crate::OffsetDateTime; use crate::convert::*; use crate::error; #[cfg(feature = "formatting")] @@ -20,8 +22,6 @@ use crate::internal_macros::ensure_ranged; use crate::parsing::Parsable; #[cfg(feature = "local-offset")] use crate::sys::local_offset_at; -#[cfg(feature = "local-offset")] -use crate::OffsetDateTime; /// The type of the `hours` field of `UtcOffset`. type Hours = RangedI8<-25, 25>;