Closed
Description
A request to create a function (for now I'll call it Ratio::into_raw
) which acts like this:
fn into_raw(self) -> (T, T) {
(self.numer, self.denom)
}
This would be useful as a way to circumvent unnecessary cloning while maintaining the "weak invariants" of Ratio
(mentioned in this issue). It would also be useful for "manually" implementing more efficient primitive operations on BigRational
from outside of num-rational like so:
fn div_by_u32(rational: BigRational, primitive: u32) -> Option<BigRational> {
(primitive != 0).then(|| {
let (numer, mut denom) = rational.into_raw();
denom *= primitive;
BigRational::new_raw(numer, denom)
})
}
This could solve issues that #38 tries to solve without making as much of a sweeping change, which hopefully will help it to be accepted more quickly.
Metadata
Metadata
Assignees
Labels
No labels