pub trait Narrow<N> {
// Required method
fn narrow(&self) -> Option<N>;
}Expand description
Storing a value in a narrower type, exactly or not at all.
§Contract
narrow returns Some(n) only when n is the same number, and None
exactly when no value of the narrow type is. It never rounds and never wraps. Widening the
result has to give back what was narrowed.
§What implements it
The rational types of this crate, into each of the fixed width rational types.
The table is deliberately smaller than Absorb’s, and not because the rest is
unwanted. Narrowing into the markers of fixed and into the primitive integers
is the other half of what makes those types worth storing, and it is simply not written yet.
The asymmetry is a gap, not a statement that those conversions do not make sense.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".