pprof_util

Trait TryCastFrom

Source
pub trait TryCastFrom<T>: Sized {
    // Required method
    fn try_cast_from(from: T) -> Option<Self>;
}
Expand description

A trait for attempted casts.

TryCast is like as, but returns None if the conversion can’t be round-tripped.

Note: there may be holes in the domain of try_cast_from, which is probably why TryFrom wasn’t implemented for floats in the standard library. For example, i64::MAX can be converted to f64, but i64::MAX - 1 can’t.

Required Methods§

Source

fn try_cast_from(from: T) -> Option<Self>

Attempts to perform the cast

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.

Implementations on Foreign Types§

Source§

impl TryCastFrom<f64> for i64

Source§

impl TryCastFrom<f64> for u64

Source§

impl TryCastFrom<i64> for f64

Source§

impl TryCastFrom<u64> for f64

Implementors§