Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustfmt docs #6202

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/calendar/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ impl<A: AsCalendar> Date<A> {
/// # Examples
///
/// ```
/// use icu::calendar::types::Weekday;
/// use icu::calendar::types::WeekOfMonth;
/// use icu::calendar::types::Weekday;
/// use icu::calendar::Date;
///
/// let date = Date::try_new_iso(2022, 8, 10).unwrap(); // second Wednesday
Expand Down
4 changes: 1 addition & 3 deletions components/calendar/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use core::marker::PhantomData;
/// # Example
///
/// ```rust
/// use icu::calendar::{
/// types::Weekday, Date, DateDuration, DateDurationUnit,
/// };
/// use icu::calendar::{types::Weekday, Date, DateDuration, DateDurationUnit};
///
/// // Creating ISO date: 1992-09-02.
/// let mut date_iso = Date::try_new_iso(1992, 9, 2)
Expand Down
6 changes: 4 additions & 2 deletions components/calendar/src/ixdtf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ impl<A: AsCalendar> Date<A> {
/// use icu::calendar::{Date, Gregorian};
///
/// let date = Date::try_from_str("2024-07-17", Gregorian).unwrap();
/// let date = Date::try_from_str("2024-07-17[u-ca=gregory]", Gregorian).unwrap();
/// let _ = Date::try_from_str("2024-07-17[u-ca=julian]", Gregorian).unwrap_err();
/// let date =
/// Date::try_from_str("2024-07-17[u-ca=gregory]", Gregorian).unwrap();
/// let _ =
/// Date::try_from_str("2024-07-17[u-ca=julian]", Gregorian).unwrap_err();
///
/// assert_eq!(date.year().era_year_or_extended(), 2024);
/// assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/src/week_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl WeekCalculator {
/// # Examples
///
/// ```
/// use icu::calendar::types::{DayOfMonth, Weekday, WeekOfMonth};
/// use icu::calendar::types::{DayOfMonth, WeekOfMonth, Weekday};
/// use icu::calendar::week::WeekCalculator;
///
/// let week_calculator =
Expand Down
8 changes: 4 additions & 4 deletions components/collator/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions components/collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//!
//! ```
//! use core::cmp::Ordering;
//! use icu::collator::{*, options::*};
//! use icu::collator::{options::*, *};
//! use icu::locale::locale;
//!
//! let mut options = CollatorOptions::default();
Expand Down Expand Up @@ -71,7 +71,7 @@
//!
//! ```
//! use core::cmp::Ordering;
//! use icu::collator::{*, options::*};
//! use icu::collator::{options::*, *};
//!
//! // Primary Level
//!
Expand Down Expand Up @@ -250,8 +250,8 @@
//!
//! ```
//! use core::cmp::Ordering;
//! use icu::collator::{*, options::*};
//! use icu::collator::preferences::*;
//! use icu::collator::{options::*, *};
//!
//! // Use the locale's default.
//!
Expand Down Expand Up @@ -286,8 +286,8 @@
//!
//! ```
//! use core::cmp::Ordering;
//! use icu::collator::{*, options::*};
//! use icu::collator::preferences::*;
//! use icu::collator::{options::*, *};
//!
//! // Numerical sorting off
//!
Expand Down
4 changes: 2 additions & 2 deletions components/collator/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum Strength {
/// to ECMA-402 sensitivity "case" with [`CaseLevel::On`].
///
/// ```
/// use icu::collator::{*, options::*};
/// use icu::collator::{options::*, *};
///
/// let mut options = CollatorOptions::default();
/// options.strength = Some(Strength::Primary);
Expand All @@ -47,7 +47,7 @@ pub enum Strength {
/// to the ECMA-402 sensitivity "accent".
///
/// ```
/// use icu::collator::{*, options::*};
/// use icu::collator::{options::*, *};
///
/// let mut options = CollatorOptions::default();
/// options.strength = Some(Strength::Secondary);
Expand Down
9 changes: 6 additions & 3 deletions components/datetime/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 12 additions & 14 deletions components/datetime/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@
//! // Medium length
//! // Always display the era
//!
//! let static_field_set = fieldsets::YMD::medium()
//! .with_year_style(YearStyle::WithEra);
//! let static_field_set =
//! fieldsets::YMD::medium().with_year_style(YearStyle::WithEra);
//!
//! let mut builder = FieldSetBuilder::new();
//! builder.date_fields = Some(DateFields::YMD);
//! builder.length = Some(Length::Medium);
//! builder.year_style = Some(YearStyle::WithEra);
//! let dynamic_field_set = builder.build_date().unwrap();
//!
//! assert_eq!(
//! dynamic_field_set,
//! DateFieldSet::YMD(static_field_set),
//! );
//! assert_eq!(dynamic_field_set, DateFieldSet::YMD(static_field_set),);
//!
//! // Standalone Month
//! // Long length
Expand All @@ -62,18 +59,15 @@
//! // Medium length, implicit in the builder
//! // Display time to the minute
//!
//! let static_field_set = fieldsets::ET::medium()
//! .with_time_precision(TimePrecision::Minute);
//! let static_field_set =
//! fieldsets::ET::medium().with_time_precision(TimePrecision::Minute);
//!
//! let mut builder = FieldSetBuilder::new();
//! builder.date_fields = Some(DateFields::E);
//! builder.time_precision = Some(TimePrecision::Minute);
//! let dynamic_field_set = builder.build_date_and_time().unwrap();
//!
//! assert_eq!(
//! dynamic_field_set,
//! DateAndTimeFieldSet::ET(static_field_set),
//! );
//! assert_eq!(dynamic_field_set, DateAndTimeFieldSet::ET(static_field_set),);
//!
//! // Time and Time Zone
//! // Short length
Expand All @@ -88,7 +82,8 @@
//!
//! let mut builder = FieldSetBuilder::new();
//! builder.length = Some(Length::Short);
//! builder.time_precision = Some(TimePrecision::Subsecond(SubsecondDigits::S3));
//! builder.time_precision =
//! Some(TimePrecision::Subsecond(SubsecondDigits::S3));
//! builder.alignment = Some(Alignment::Column);
//! builder.zone_style = Some(ZoneStyle::SpecificLong);
//! let dynamic_field_set = builder.build_composite().unwrap();
Expand Down Expand Up @@ -246,7 +241,10 @@ mod _serde {
///
/// let json_str = serde_json::to_string(&builder).unwrap();
///
/// assert_eq!(json_str, r#"{"length":"medium","dateFields":"YMD","yearStyle":"withEra"}"#);
/// assert_eq!(
/// json_str,
/// r#"{"length":"medium","dateFields":"YMD","yearStyle":"withEra"}"#
/// );
///
/// let json_parsed = serde_json::from_str(&json_str).unwrap();
///
Expand Down
55 changes: 30 additions & 25 deletions components/datetime/src/combo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ use crate::{provider::neo::*, scaffold::*};
/// Only one way to construct a combo field set (in this case, weekday with location-based zone):
///
/// ```
/// use icu::datetime::fieldsets::{Combo, E, zone::Location};
/// use icu::datetime::fieldsets::{zone::Location, Combo, E};
///
/// let field_set = E::long().zone(Location);
/// ```
///
/// Format the weekday, hour, and location-based zone:
///
/// ```
/// use icu::datetime::fieldsets::{Combo, ET, zone::Location};
/// use icu::datetime::fieldsets::{zone::Location, Combo, ET};
/// use icu::datetime::input::ZonedDateTime;
/// use icu::datetime::DateTimeFormatter;
/// use icu::locale::locale;
/// use icu::datetime::input::ZonedDateTime;
/// use icu::time::zone::IanaParser;
/// use writeable::assert_writeable_eq;
///
Expand Down Expand Up @@ -53,23 +53,28 @@ use crate::{provider::neo::*, scaffold::*};
///
/// ```
/// use icu::calendar::Gregorian;
/// use icu::datetime::fieldsets::{Combo, ET, zone::Location};
/// use icu::datetime::fieldsets::{zone::Location, Combo, ET};
/// use icu::datetime::input::ZonedDateTime;
/// use icu::datetime::FixedCalendarDateTimeFormatter;
/// use icu::locale::locale;
/// use icu::datetime::input::ZonedDateTime;
/// use icu::time::zone::IanaParser;
/// use writeable::assert_writeable_eq;
///
/// // Note: Combo type can be elided, but it is shown here for demonstration
/// let formatter = FixedCalendarDateTimeFormatter::<_, Combo<ET, Location>>::try_new(
/// locale!("en-US").into(),
/// ET::short().hm().zone(Location),
/// let formatter =
/// FixedCalendarDateTimeFormatter::<_, Combo<ET, Location>>::try_new(
/// locale!("en-US").into(),
/// ET::short().hm().zone(Location),
/// )
/// .unwrap();
///
/// let zdt = ZonedDateTime::try_location_only_from_str(
/// "2024-10-18T15:44[America/Los_Angeles]",
/// Gregorian,
/// IanaParser::new(),
/// )
/// .unwrap();
///
/// let zdt = ZonedDateTime::try_location_only_from_str("2024-10-18T15:44[America/Los_Angeles]", Gregorian, IanaParser::new())
/// .unwrap();
///
/// assert_writeable_eq!(
/// formatter.format(&zdt),
/// "Fri, 3:44 PM Los Angeles Time"
Expand All @@ -80,19 +85,22 @@ use crate::{provider::neo::*, scaffold::*};
/// with a static time zone:
///
/// ```
/// use icu::datetime::fieldsets::{enums::DateFieldSet, Combo, zone::GenericShort, YMD};
/// use icu::datetime::fieldsets::{
/// enums::DateFieldSet, zone::GenericShort, Combo, YMD,
/// };
/// use icu::datetime::input::ZonedDateTime;
/// use icu::datetime::DateTimeFormatter;
/// use icu::locale::locale;
/// use icu::datetime::input::ZonedDateTime;
/// use icu::time::zone::IanaParser;
/// use writeable::assert_writeable_eq;
///
/// // Note: Combo type can be elided, but it is shown here for demonstration
/// let formatter = DateTimeFormatter::<Combo<DateFieldSet, GenericShort>>::try_new(
/// locale!("en-US").into(),
/// DateFieldSet::YMD(YMD::long()).zone(GenericShort),
/// )
/// .unwrap();
/// let formatter =
/// DateTimeFormatter::<Combo<DateFieldSet, GenericShort>>::try_new(
/// locale!("en-US").into(),
/// DateFieldSet::YMD(YMD::long()).zone(GenericShort),
/// )
/// .unwrap();
///
/// let zdt = ZonedDateTime::try_location_only_from_str(
/// "2024-10-18T15:44[America/Los_Angeles]",
Expand All @@ -101,21 +109,18 @@ use crate::{provider::neo::*, scaffold::*};
/// )
/// .unwrap();
///
/// assert_writeable_eq!(
/// formatter.format(&zdt),
/// "October 18, 2024 PT"
/// );
/// assert_writeable_eq!(formatter.format(&zdt), "October 18, 2024 PT");
/// ```
///
/// Format with a time of day and long time zone:
///
/// ```
/// use icu::calendar::Gregorian;
/// use icu::datetime::fieldsets::{T, zone::SpecificLong};
/// use icu::datetime::fieldsets::{zone::SpecificLong, T};
/// use icu::datetime::input::ZonedDateTime;
/// use icu::datetime::FixedCalendarDateTimeFormatter;
/// use icu::locale::locale;
/// use icu::datetime::input::ZonedDateTime;
/// use icu::time::zone::{UtcOffsetCalculator, IanaParser};
/// use icu::time::zone::{IanaParser, UtcOffsetCalculator};
/// use writeable::assert_writeable_eq;
///
/// let formatter = FixedCalendarDateTimeFormatter::try_new(
Expand Down
7 changes: 5 additions & 2 deletions components/datetime/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
//! use icu::calendar::Date;
//! use icu::datetime::fieldsets;
//! use icu::datetime::fieldsets::enums::CompositeDateTimeFieldSet;
//! use icu::datetime::input::{DateTime, Time};
//! use icu::datetime::DateTimeFormatter;
//! use icu::locale::locale;
//! use icu::datetime::input::{DateTime, Time};
//! use writeable::Writeable;
//!
//! fn get_field_set(should_display_time: bool) -> CompositeDateTimeFieldSet {
Expand All @@ -50,7 +50,10 @@
//! }
//! }
//!
//! let datetime = DateTime { date: Date::try_new_iso(2025, 1, 15).unwrap(), time: Time::try_new(16, 0, 0, 0).unwrap() };
//! let datetime = DateTime {
//! date: Date::try_new_iso(2025, 1, 15).unwrap(),
//! time: Time::try_new(16, 0, 0, 0).unwrap(),
//! };
//!
//! let results = [true, false]
//! .map(get_field_set)
Expand Down
9 changes: 6 additions & 3 deletions components/datetime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
//! # Examples
//!
//! ```
//! use icu::datetime::input::Date;
//! use icu::datetime::fieldsets;
//! use icu::datetime::input::Date;
//! use icu::datetime::input::{DateTime, Time};
//! use icu::datetime::DateTimeFormatter;
//! use icu::locale::{locale, Locale};
//! use icu::datetime::input::{DateTime, Time};
//! use writeable::assert_writeable_eq;
//!
//! // Field set for year, month, day, hour, and minute with a medium length:
Expand All @@ -64,7 +64,10 @@
//! let dtf = DateTimeFormatter::try_new(locale.into(), field_set).unwrap();
//!
//! // Format something:
//! let datetime = DateTime { date: Date::try_new_iso(2025, 1, 15).unwrap(), time: Time::try_new(16, 9, 35, 0).unwrap() };
//! let datetime = DateTime {
//! date: Date::try_new_iso(2025, 1, 15).unwrap(),
//! time: Time::try_new(16, 9, 35, 0).unwrap(),
//! };
//! let formatted_date = dtf.format(&datetime);
//!
//! assert_writeable_eq!(formatted_date, "15 de ene de 2025, 4:09 p. m.");
Expand Down
Loading