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]

[src]

Gets the mutable numerator.

[src]

Gets the mutable denominator.

[src]

Gets the mutable numerator and denominator.

Trait Implementations

impl<'a> Drop for MutNumerDenom<'a>
[src]

[src]

Executes the destructor for this type. Read more