Trait DecimalCast

Source
pub(crate) trait DecimalCast: Sized {
    // Required methods
    fn to_i128(self) -> Option<i128>;
    fn to_i256(self) -> Option<i256>;
    fn from_decimal<T: DecimalCast>(n: T) -> Option<Self>;
    fn from_f64(n: f64) -> Option<Self>;
}
Expand description

A utility trait that provides checked conversions between decimal types inspired by NumCast

Required Methods§

Source

fn to_i128(self) -> Option<i128>

Source

fn to_i256(self) -> Option<i256>

Source

fn from_decimal<T: DecimalCast>(n: T) -> Option<Self>

Source

fn from_f64(n: f64) -> Option<Self>

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 DecimalCast for i128

Source§

fn to_i128(self) -> Option<i128>

Source§

fn to_i256(self) -> Option<i256>

Source§

fn from_decimal<T: DecimalCast>(n: T) -> Option<Self>

Source§

fn from_f64(n: f64) -> Option<Self>

Source§

impl DecimalCast for i256

Source§

fn to_i128(self) -> Option<i128>

Source§

fn to_i256(self) -> Option<i256>

Source§

fn from_decimal<T: DecimalCast>(n: T) -> Option<Self>

Source§

fn from_f64(n: f64) -> Option<Self>

Implementors§