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

extra: Add getter methods to extra::rational::Ratio #10050

Merged
merged 1 commit into from
Oct 28, 2013
Merged

extra: Add getter methods to extra::rational::Ratio #10050

merged 1 commit into from
Oct 28, 2013

Conversation

gifnksm
Copy link
Contributor

@gifnksm gifnksm commented Oct 24, 2013

After merging 0ada7c7, user code have not been able to access to Ratio's numerator and denominator fields.
In some algorithms, it is needed to get an rational number's numerator or denominator, but keeping these fields private is necessary for guaranteeing that Ratio numbers are irreducible.
So, I added the getter methods numer() and denom().

As a bonus, this commit adds utility methods relating to the ratio-integer conversion.

After merging 0ada7c7, user code have not been able to access to `Ratio`'s numerator and denominator fields.
In some algorithms, it is needed to get an rational number's numerator or denominator, but keeping these fields private is necessary for guaranteeing that `Ratio` numbers are irreducible.
So, I added the getter methods `numer()` and `denom()`.

As a bonus, this commit adds utility methods relating to the ratio-integer conversion.
@alexcrichton
Copy link
Member

I believe that the fields of this struct were erroneously made private, these should really be public fields for all to inspect.

@gifnksm
Copy link
Contributor Author

gifnksm commented Oct 25, 2013

@alexcrichton As discussed in #5738, making these fields private has some merits. I think we should employ the same normalizing policy with gmp.

bors added a commit that referenced this pull request Oct 28, 2013
After merging 0ada7c7, user code have not been able to access to `Ratio`'s numerator and denominator fields.
In some algorithms, it is needed to get an rational number's numerator or denominator, but keeping these fields private is necessary for guaranteeing that `Ratio` numbers are irreducible.
So, I added the getter methods `numer()` and `denom()`.

As a bonus, this commit adds utility methods relating to the ratio-integer conversion.
@bors bors closed this Oct 28, 2013
@bors bors merged commit 7d5c7b8 into rust-lang:master Oct 28, 2013
@gifnksm gifnksm deleted the ratio-methods branch November 4, 2013 02:26
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.

3 participants