icu4x icon indicating copy to clipboard operation
icu4x copied to clipboard

FixedDecimal `*ed` methods should be infallible

Open sffc opened this issue 3 months ago • 5 comments

This function is misleading:

pub fn concatenated_end(self, other: FixedDecimal) -> Result<Self, FixedDecimal>

In the error case, it returns other, but it still throws away self. It should probably return a tuple containing both FixedDecimals. It makes it tempting to write code such as mantissa.concatenated_end(fraction).unwrap_or_else(|fd| fd), which is wrong because it promotes fraction when it should probably keep mantissa and throw away fraction.

I think we should delete this function since it is only sugar over concatenate_end, which is harder to use incorrectly.

sffc avatar May 02 '24 00:05 sffc