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);