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

Remove unnecessary verbosity in error docs/Display #5972

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 10 additions & 8 deletions components/experimental/src/duration/validated_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,23 @@ pub struct ValidatedDurationFormatterOptions {
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, displaydoc::Display)]
pub enum DurationFormatterOptionsError {
/// Returned when a unit field is set to [`FieldDisplay::Always`] and the style is set to [`FieldStyle::Fractional`].
#[displaydoc("Returned when a unit field is set to Always and the style is set to Fractional")]
/// A unit field is set to [`FieldDisplay::Always`] and the style is set to [`FieldStyle::Fractional`].
#[displaydoc("A unit field is set to Always and the style is set to Fractional")]
DisplayAlwaysFractional,

/// Returned when a previous unit's style is [`FieldStyle::Fractional`], but the following unit's style is not [`FieldStyle::Fractional`].
#[displaydoc("Returned when a previous unit's style is Fractional, but the following unit's style is not Fractional")]
/// A previous unit's style is [`FieldStyle::Fractional`], but the following unit's style is not [`FieldStyle::Fractional`].
#[displaydoc(
"A previous unit's style is Fractional, but the following unit's style is not Fractional"
)]
PreviousFractional,

/// Returned when a previous unit's style is set to [`FieldStyle::Numeric`] or [`FieldStyle::TwoDigit`] and the following unit's style is not
/// A previous unit's style is set to [`FieldStyle::Numeric`] or [`FieldStyle::TwoDigit`] and the following unit's style is not
/// [`FieldStyle::Fractional`], [`FieldStyle::Numeric`], or [`FieldStyle::TwoDigit`].
#[displaydoc("Returned when a previous unit's style is set to Numeric or TwoDigit and the following unit's style is not Fractional, Numeric, or TwoDigit")]
#[displaydoc("A previous unit's style is set to Numeric or TwoDigit and the following unit's style is not Fractional, Numeric, or TwoDigit")]
PreviousNumeric,

/// Returned when the number of fractional digits is out of acceptable range. See [`FractionalDigits::Fixed`].
#[displaydoc("Returned when the number of fractional digits is out of acceptable range")]
/// The number of fractional digits is out of acceptable range. See [`FractionalDigits::Fixed`].
#[displaydoc("Returned when tThehe number of fractional digits is out of acceptable range")]
Manishearth marked this conversation as resolved.
Show resolved Hide resolved
FractionalDigitsOutOfRange,
}

Expand Down
32 changes: 13 additions & 19 deletions components/experimental/src/units/ratio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,43 @@ use crate::measure::provider::si_prefix::{Base, SiPrefix};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct IcuRatio(Ratio<BigInt>);

/// Represents an error when the ratio string is invalid and cannot be parsed.
/// The ratio string is invalid and cannot be parsed.
#[derive(Debug, PartialEq, displaydoc::Display)]
pub enum RatioFromStrError {
/// Represents an error when the ratio string is divided by zero.
/// The ratio string is divided by zero.
DivisionByZero,

/// Represents an error when the ratio string contains multiple slashes.
/// The ratio string contains multiple slashes.
///
/// For example, "1/2/3".
#[displaydoc("Represents an error when the ratio string contains multiple slashes")]
#[displaydoc("The ratio string contains multiple slashes")]
MultipleSlashes,

/// Represents an error when the ratio string contains non-numeric characters in fractions.
/// The ratio string contains non-numeric characters in fractions.
///
/// For example, "1/2A".
#[displaydoc(
"Represents an error when the ratio string contains non-numeric characters in fractions"
)]
#[displaydoc("The ratio string contains non-numeric characters in fractions")]
NonNumericCharactersInFractions,

/// Represents an error when the ratio string contains multiple scientific notations.
/// The ratio string contains multiple scientific notations.
///
/// For example, "1.5E6E6".
#[displaydoc(
"Represents an error when the ratio string contains multiple scientific notations"
)]
#[displaydoc("The ratio string contains multiple scientific notations")]
MultipleScientificNotations,

/// Represents an error when the ratio string contains multiple decimal points.
/// The ratio string contains multiple decimal points.
///
/// For example, "1.5.6".
#[displaydoc("Represents an error when the ratio string contains multiple decimal points")]
#[displaydoc("The ratio string contains multiple decimal points")]
MultipleDecimalPoints,

/// Represents an error when the exponent part of the ratio string is not an integer.
/// The exponent part of the ratio string is not an integer.
///
/// For example, "1.5E6.5".
#[displaydoc(
"Represents an error when the exponent part of the ratio string is not an integer"
)]
#[displaydoc("The exponent part of the ratio string is not an integer")]
ExponentPartIsNotAnInteger,

/// Represents an error when the ratio string is dificient in some other way.
/// The ratio string is dificient in some other way.
Manishearth marked this conversation as resolved.
Show resolved Hide resolved
ParsingBigIntError(num_bigint::ParseBigIntError),
}

Expand Down
Loading