Skip to content

Commit

Permalink
Return Err((self, other)) in FixedDecimal::concatenated_end (#5623)
Browse files Browse the repository at this point in the history
Fixes #4857

I think that's the only `fn *ed* -> Result` that we have.

<!--
Thank you for your pull request to ICU4X!

Reminder: try to use [Conventional
Comments](https://conventionalcomments.org/) to make comments clearer.

Please see
https://github.com/unicode-org/icu4x/blob/main/CONTRIBUTING.md for
general
information on contributing to ICU4X.
-->
  • Loading branch information
Manishearth authored Oct 1, 2024
1 parent a3ebd13 commit 1d17017
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `icu_locale`
- New crate
- `icu_locale_core`
- New crate, split out of `icu_locid`
- New crate, renamed from `icu_locid`
- Removed `Ord` and `PartialOrd` impl from `extensions::unicode::Unicode` (https://github.com/unicode-org/icu4x/pull/5617)
- `icu_locid_transform`
- `icu_plurals`
Expand All @@ -35,6 +35,7 @@
- `calendrical_calculations`:
- `databake`
- `fixed_decimal`
- `FixedDecimal::concatenated_end()` now returns both `self` and `other` in the error case. (https://github.com/unicode-org/icu4x/pull/5623)
- `icu_pattern`
- `litemap`
- `yoke`
Expand Down
9 changes: 6 additions & 3 deletions utils/fixed_decimal/src/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ impl FixedDecimal {
///
/// All nonzero digits in `other` must have lower magnitude than nonzero digits in `self`.
/// If the two decimals represent overlapping ranges of magnitudes, an `Err` is returned,
/// passing ownership of `other` back to the caller.
/// containing (self, other).
///
/// The magnitude range of `self` will be increased if `other` covers a larger range.
///
Expand All @@ -2237,10 +2237,13 @@ impl FixedDecimal {
///
/// assert_eq!("123.456", result.to_string());
/// ```
pub fn concatenated_end(mut self, other: FixedDecimal) -> Result<Self, FixedDecimal> {
pub fn concatenated_end(
mut self,
other: FixedDecimal,
) -> Result<Self, (FixedDecimal, FixedDecimal)> {
match self.concatenate_end(other) {
Ok(()) => Ok(self),
Err(err) => Err(err),
Err(err) => Err((self, err)),
}
}

Expand Down

0 comments on commit 1d17017

Please sign in to comment.