Skip to content

Commit

Permalink
- make options fields pub and struct non exhaustive
Browse files Browse the repository at this point in the history
- mark all enums non exhaustive

- remove reference to DurationFormatter to remove doc warning
(will add when DurationFormatter exists)
  • Loading branch information
kartva committed Jun 7, 2024
1 parent 04cf71e commit 362f77e
Showing 1 changed file with 59 additions and 24 deletions.
83 changes: 59 additions & 24 deletions components/experimental/src/duration/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,61 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

//! Options for configuring [`DurationFormatter`](crate::duration::DurationFormatter).
//! Options for configuring `DurationFormatter`.
/// A bag of options for defining how to format duration using [`DurationFormatter`](crate::duration::DurationFormatter).
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct DurationFormatterOptions {
base: BaseStyle,

year: YearStyle,
year_visibility: UnitVisibility,
month: MonthStyle,
month_visibility: UnitVisibility,
week: WeekStyle,
week_visibility: UnitVisibility,
day: DayStyle,
day_visibility: UnitVisibility,
hour: HourStyle,
hour_visibility: UnitVisibility,
minute: MinuteStyle,
minute_visibility: UnitVisibility,
second: SecondStyle,
second_visibility: UnitVisibility,
millisecond: MilliSecondStyle,
millisecond_visibility: UnitVisibility,
microsecond: MicroSecondStyle,
microsecond_visibility: UnitVisibility,
nanosecond: NanoSecondStyle,
nanosecond_visibility: UnitVisibility,
/// The style that will be applied to units
/// unless overridden by a specific style.
pub base: BaseStyle,

/// Style for year
pub year: YearStyle,
/// Visibility control for year
pub year_visibility: UnitVisibility,
/// Style for month
pub month: MonthStyle,
/// Visibility control for month
pub month_visibility: UnitVisibility,
/// Style for week
pub week: WeekStyle,
/// Visibility control for week
pub week_visibility: UnitVisibility,
/// Style for day
pub day: DayStyle,
/// Visibility control for day
pub day_visibility: UnitVisibility,
/// Style for hour
pub hour: HourStyle,
/// Visibility control for hour
pub hour_visibility: UnitVisibility,
/// Style for minute
pub minute: MinuteStyle,
/// Visibility control for minute
pub minute_visibility: UnitVisibility,
/// Style for second
pub second: SecondStyle,
/// Visibility control for second
pub second_visibility: UnitVisibility,
/// Style for millisecond
pub millisecond: MilliSecondStyle,
/// Visibility control for millisecond
pub millisecond_visibility: UnitVisibility,
/// Style for microsecond
pub microsecond: MicroSecondStyle,
/// Visibility control for microsecond
pub microsecond_visibility: UnitVisibility,
/// Style for nanosecond
pub nanosecond: NanoSecondStyle,
/// Visibility control for nanosecond
pub nanosecond_visibility: UnitVisibility,

/// Number of fractional digits to use when formatting sub-second units (milliseconds, microseconds, nanoseconds).
/// Only takes effect when the subsecond units are styled as `Numeric`.
/// Zero means no fractional digits.
fractional_digits: FractionalDigits,
pub fractional_digits: FractionalDigits,
}

/// Options for configuring the number of fractional digits to display.
Expand All @@ -49,6 +72,7 @@ pub enum FractionalDigits {
}

/// Configures visibility of fields in the formatted string.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum UnitVisibility {
#[default]
Expand All @@ -59,6 +83,7 @@ pub enum UnitVisibility {
}

/// Configures the style of the duration output.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum BaseStyle {
/// Narrow style (most compact)
Expand All @@ -73,6 +98,7 @@ pub enum BaseStyle {
}

/// Configures the style of the year field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum YearStyle {
/// Narrow style (most compact)
Expand All @@ -85,6 +111,7 @@ pub enum YearStyle {
}

/// Configures the style of the month field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum MonthStyle {
/// Narrow style (most compact)
Expand All @@ -97,6 +124,7 @@ pub enum MonthStyle {
}

/// Configures the style of the week field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum WeekStyle {
/// Narrow style (most compact)
Expand All @@ -109,6 +137,7 @@ pub enum WeekStyle {
}

/// Configures the style of the day field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum DayStyle {
/// Narrow style (most compact)
Expand All @@ -121,6 +150,7 @@ pub enum DayStyle {
}

/// Configures the style of the hour field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum HourStyle {
/// Narrow style (most compact)
Expand All @@ -137,6 +167,7 @@ pub enum HourStyle {
}

/// Configures the style of the minute field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum MinuteStyle {
/// Narrow style (most compact)
Expand All @@ -153,6 +184,7 @@ pub enum MinuteStyle {
}

/// Configures the style of the second field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum SecondStyle {
/// Narrow style (most compact)
Expand All @@ -169,6 +201,7 @@ pub enum SecondStyle {
}

/// Configures the style of the milliseconds field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum MilliSecondStyle {
/// Narrow style (most compact)
Expand All @@ -183,6 +216,7 @@ pub enum MilliSecondStyle {
}

/// Configures the style of the microsecond field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum MicroSecondStyle {
/// Narrow style (most compact)
Expand All @@ -197,6 +231,7 @@ pub enum MicroSecondStyle {
}

/// Configures the style of the nanosecond field.
#[non_exhaustive]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum NanoSecondStyle {
/// Narrow style (most compact)
Expand Down

0 comments on commit 362f77e

Please sign in to comment.