Struct rug::rational::MutNumerDenom
[−]
[src]
pub struct MutNumerDenom<'a> { /* fields omitted */ }
Used to borrow the numerator and denominator of a
Rational
number mutably.
The Rational
number is canonicalized
when the borrow ends.
See the Rational::as_mut_numer_denom
method.
Examples
use rug::Rational; let mut r = Rational::from((3, 5)); { let mut num_den = r.as_mut_numer_denom(); // change r from 3/5 to 4/8, which is equal to 1/2 *num_den.num() += 1; *num_den.den() += 3; // borrow ends here } let num_den = r.as_numer_denom(); assert_eq!(*num_den.0, 1); assert_eq!(*num_den.1, 2);
Methods
impl<'a> MutNumerDenom<'a>
[src]
fn num(&mut self) -> &mut Integer
[src]
Gets the mutable numerator.
fn den(&mut self) -> &mut Integer
[src]
Gets the mutable denominator.
fn num_den(&mut self) -> (&mut Integer, &mut Integer)
[src]
Gets the mutable numerator and denominator.