Trait sp_runtime::SaturatedConversion
source · pub trait SaturatedConversion {
// Provided methods
fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T> { ... }
fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T> { ... }
}
Expand description
Re-export top-level arithmetic stuff.
Convenience type to work around the highly unergonomic syntax needed
to invoke the functions of overloaded generic traits, in this case
SaturatedFrom
and SaturatedInto
.
Provided Methods§
sourcefn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
Convert from a value of T
into an equivalent instance of Self
.
This just uses UniqueSaturatedFrom
internally but with this
variant you can provide the destination type using turbofish syntax
in case Rust happens not to assume the correct type.
sourcefn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
.
This just uses UniqueSaturatedInto
internally but with this
variant you can provide the destination type using turbofish syntax
in case Rust happens not to assume the correct type.