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

Remove unneeded to_f64 funciton #4839

Merged
merged 14 commits into from May 14, 2024
Merged

Conversation

younies
Copy link
Member

@younies younies commented Apr 24, 2024

No description provided.

@younies younies requested a review from a team as a code owner April 24, 2024 04:57
@younies younies requested review from robertbastian and removed request for a team April 24, 2024 04:57
Copy link
Member

@robertbastian robertbastian left a comment

Choose a reason for hiding this comment

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

Actually why not use ratio.get_ratio().to_f64()?

@younies
Copy link
Member Author

younies commented Apr 24, 2024

Actually why not use ratio.get_ratio().to_f64()?

either way, we need to have the feature of "big-int", also, get_ratio() should consume the object.

and what is the point of have IcuRatio if we are going to get_ratio() for all the operations?

as in #4841.

@robertbastian
Copy link
Member

get_ratio() should consume the object

You'll need both, checking .is_reciprocal() should not consume.

and what is the point of have IcuRatio if we are going to get_ratio() for all the operations?

That you can define things like impl Mul<SiPrefix>, which you cannot for BigRational

Copy link
Member

@robertbastian robertbastian left a comment

Choose a reason for hiding this comment

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

.

@younies younies changed the title Fix to_f64 in IcuRatio Remove unneeded to_f64 funciton Apr 25, 2024
@@ -69,7 +69,7 @@ fn test_cldr_unit_tests() {
);
}

let test_result_f64 = test.result.to_f64().unwrap();
let test_result_f64 = test.result.clone().get_ratio().to_f64().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

This is why there should also be a -> &BigRational method, this clone is not necessary because to_f64 doesn't need ownership. However, given that this is in-crate, you can use test.result.0.to_f64()

@younies
Copy link
Member Author

younies commented May 8, 2024

You'll need both, checking .is_reciprocal() should not consume.

I prefer that these functions to be implemented for IcuRatio

@younies younies requested a review from robertbastian May 8, 2024 14:10
@younies younies merged commit afe6679 into unicode-org:main May 14, 2024
30 checks passed
@younies younies deleted the dev-fix-to-f64 branch May 14, 2024 10:42
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.

None yet

2 participants