pub trait InfCast<TI>: Sized {
// Required methods
fn inf_cast(v: TI) -> Fallible<Self>;
fn neg_inf_cast(v: TI) -> Fallible<Self>;
}
Expand description
Fallible casting where the casted value rounds towards infinity.
This preserves the invariant that the casted value is gte the original value. For example, casting a 128_u8 to i8 doesn’t saturate to i8::MAX (127), it errors.
Required Methods§
sourcefn inf_cast(v: TI) -> Fallible<Self>
fn inf_cast(v: TI) -> Fallible<Self>
Proof Definition
For any v
of type TI
, Self::inf_cast(value)
either returns Err(e)
,
or Ok(out)
where $out \ge v$.
sourcefn neg_inf_cast(v: TI) -> Fallible<Self>
fn neg_inf_cast(v: TI) -> Fallible<Self>
Proof Definition
For any v
of type TI
, Self::inf_cast(value)
either returns Err(e)
,
or Ok(out)
where $out \le v$.