pub trait AsCast: AsPrimitive {
// Required method
fn as_cast<N: AsPrimitive>(n: N) -> Self;
}
Expand description
An interface for casting between machine scalars, as if as
was used.
All values that the type can be cast to must be primitive
values.
Required Methods§
Sourcefn as_cast<N: AsPrimitive>(n: N) -> Self
fn as_cast<N: AsPrimitive>(n: N) -> Self
Creates a number from another value that can be converted into
a primitive via the AsPrimitive
trait.
§Examples
use lexical_util::num::AsCast;
assert_eq!(u8::as_cast(256u16), 256u16 as u8); // 0
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.