Skip to content

Conversation

c410-f3r
Copy link
Contributor

@c410-f3r c410-f3r commented Sep 14, 2025

Something I didn't realize in #360, rust_decimal::Error conflicts with CTFE (Constant Time Function Evaluator) because of the variants that use String.

For example, the following should be possible but isn't at the current time.

const FOO: Decimal = match Decimal::try_new(0, 0) {
    Ok(num) => num,
    Err(_) => panic!(),
};
destructor of `core::result::Result<decimal::Decimal, error::Error>` cannot be evaluated at compile-time
the destructor for this type cannot be evaluated in constants

The idea to workaround this limitation is to convert all string errors into error variants starting with the from_scientific_exact function. Technically a breaking change but such a thing already occurred before without a version bump.

Feel free to close this PR if desired.

Comment on lines -41 to -42
#[cfg(feature = "std")]
impl std::error::Error for Error {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary anymore

@paupino
Copy link
Owner

paupino commented Sep 15, 2025

Given this is merging into the "vnext" version which is intended to be breaking, this seems perfectly fine - in fact, desired! Thank you

@paupino paupino merged commit 8e97c2c into paupino:master Sep 15, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants