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

refactor: tidy up decimal module #294

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

JayWhite2357
Copy link
Contributor

@JayWhite2357 JayWhite2357 commented Oct 22, 2024

Rationale for this change

After #283, the math::decimal module is a bit untidy, especially around error types and tests.

What changes are included in this PR?

This reorganizes the module, tidies things up, and adds some more thorough unit tests.
Please look at the individual commits since there is a lot of code moved, and the individual commits are smaller than the aggregate.

Are these changes tested?

Yes

pub trait BigDecimalExt {
fn precision(&self) -> u64;
fn scale(&self) -> i64;
fn try_into_bigint_with_precision_and_scale(
/// Fallibly attempts to convert an `IntermediateDecimal` into the
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think we have the IntermediateDecimal type anymore?

#[derive(Eq, PartialEq, Debug, Clone, Hash, Serialize, Copy)]
/// limit-enforced precision
pub struct Precision(u8);
pub(super) const MAX_SUPPORTED_PRECISION: u8 = 75;
Copy link
Contributor

Choose a reason for hiding this comment

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

this could use a doc comment

},
}
})?;
let _max_precision = Precision::new(max_precision_value)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this unused? would it be better to have a check function that didnt require an unused variable?

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