pub trait ExactArith: Cost {
type Exact: ExactNumber;
// Required method
fn exact(self) -> Self::Exact;
}Expand description
A cost that converts into an ExactNumber without loss.
An additive companion of Cost and WideMul: cost
types without it keep working everywhere else.
| Cost | Exact |
|---|---|
u8 to u128, usize | BigUint |
Decimal<K> | BigUint of the raw value (scale 10^K) |
NonNegF64 (feature float) | NonNegF64 |
§Examples
use search_core::ExactArith;
// (d1 · c1 + s) · c2 against (d2 · c2 + s) · c1 without overflow.
let e = |x: u64| x.exact();
let left = (e(u64::MAX) * e(u64::MAX) + e(7)) * e(u64::MAX);
let right = (e(1) * e(u64::MAX) + e(7)) * e(u64::MAX);
assert!(left > right);Required Associated Types§
Sourcetype Exact: ExactNumber
type Exact: ExactNumber
The exact number type.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".