Trait rug::Complete

source ·
pub trait Complete {
    type Completed;

    // Required method
    fn complete(self) -> Self::Completed;

    // Provided method
    fn complete_into<T>(self, target: &mut T)
       where Self: Sized,
             T: Assign<Self> { ... }
}
Expand description

Completes an incomplete-computation value.

§Examples

Implementing the trait:

use rug::{Complete, Integer};
struct LazyPow4<'a>(&'a Integer);
impl Complete for LazyPow4<'_> {
    type Completed = Integer;
    fn complete(self) -> Integer {
        self.0.clone().square().square()
    }
}

assert_eq!(LazyPow4(&Integer::from(3)).complete(), 3i32.pow(4));

Completing an incomplete-computation value:

use rug::{Complete, Integer};
let incomplete = Integer::fibonacci(12);
let complete = incomplete.complete();
assert_eq!(complete, 144);

Required Associated Types§

source

type Completed

The type of the completed operation.

Required Methods§

source

fn complete(self) -> Self::Completed

Completes the operation.

Provided Methods§

source

fn complete_into<T>(self, target: &mut T)
where Self: Sized, T: Assign<Self>,

Completes the operation and stores the result in a target.

§Examples
use rug::{Complete, Integer};
let mut complete = Integer::new();
Integer::fibonacci(12).complete_into(&mut complete);
assert_eq!(complete, 144);

Implementors§