TryFromValueCoerce

Trait TryFromValueCoerce 

Source
pub trait TryFromValueCoerce: Sized {
    // Required method
    fn try_from_value_coerce(value: &Value) -> Result<Self, FromValueError>;

    // Provided method
    fn from_value_coerce(value: &Value) -> Option<Self> { ... }
}
Expand description

Trait for widening extraction of Rust types from Value.

Unlike TryFromValue, this allows compatible type conversions:

  • i64 can be extracted from Int1, Int2, Int4, or Int8
  • u64 can be extracted from Uint1, Uint2, Uint4, or Uint8
  • f64 can be extracted from Float4, Float8, or any integer type

Required Methods§

Source

fn try_from_value_coerce(value: &Value) -> Result<Self, FromValueError>

Attempt to extract with widening conversion.

Provided Methods§

Source

fn from_value_coerce(value: &Value) -> Option<Self>

Extract with coercion, returning None for Undefined or incompatible types.

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 TryFromValueCoerce for f64

Source§

impl TryFromValueCoerce for i64

Source§

impl TryFromValueCoerce for i128

Source§

impl TryFromValueCoerce for u64

Source§

impl TryFromValueCoerce for u128

Implementors§