Skip to content

Commit

Permalink
doc: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kartva committed Jul 1, 2024
1 parent e4934c7 commit f5890da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub struct ValidatedDurationFormatterOptions {
fractional_digits: FractionalDigits,
}

/// Error type for [DurationFormatterOptions] validation.
#[non_exhaustive]
pub enum DurationFormatterOptionsError {
InvalidFractionalDigits,
Expand Down Expand Up @@ -179,6 +180,8 @@ impl ValidatedDurationFormatterOptions {
Ok(builder.try_into().unwrap())
}

/// Iterates over all unit fields of the struct, returning a tuple of the unit,
/// and mutable references to its style and the visibility.
#[allow(dead_code)]
pub(crate) fn iter_units(&mut self) -> [(Unit, &mut FieldStyle, &mut FieldDisplay); 10] {
[
Expand Down Expand Up @@ -341,6 +344,7 @@ pub(crate) enum Unit {
}

impl Unit {
/// Returns the default digital style for the unit.
pub(crate) fn digital_default(&self) -> FieldStyle {
match self {
Unit::Year => YearStyle::Short.into(),
Expand Down
2 changes: 2 additions & 0 deletions components/experimental/src/duration/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pub enum FieldDisplay {
Always,
}

/// Enum used to process different unit styles in a generic way.
/// Implements `From` and `TryFrom` for all unit enums.
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum FieldStyle {
Expand Down

0 comments on commit f5890da

Please sign in to comment.