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

Fix parse error in formatter example #1842

Merged
merged 1 commit into from
Jul 1, 2021
Merged
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
3 changes: 2 additions & 1 deletion druid/examples/value_formatting/src/formatters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl Formatter<f64> for NaiveCurrencyFormatter {
Validation::failure(CurrencyValidationError::TooManyCharsAfterDecimal)
}
(Some(c), None, _) if c.is_ascii_digit() => Validation::success(),
(Some(c), None, _) => Validation::failure(CurrencyValidationError::InvalidChar(c)),
(None, None, _) => Validation::success(),
(Some(c1), Some(c2), _) if c1.is_ascii_digit() && c2.is_ascii_digit() => {
Validation::success()
Expand All @@ -173,7 +174,7 @@ impl Formatter<f64> for NaiveCurrencyFormatter {
let bad_char = if c1.is_ascii_digit() { other } else { c1 };
Validation::failure(CurrencyValidationError::InvalidChar(bad_char))
}
_ => unreachable!(),
other => panic!("unexpected: {:?}", other),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why other vs _? Just curious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so that I had a simple binding I could print to see what the failure was. Probably don't need to commit, but seems more useful anyway..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh haha I see now, I didnt notice you use it too.

}
}
}
Expand Down