Skip to main content

CoercionPolicy

Trait CoercionPolicy 

Source
pub trait CoercionPolicy: Send + Sync {
    // Required methods
    fn to_number(&self, cx: &mut Cx, value: &Value) -> Result<Option<Value>>;
    fn to_string(&self, cx: &mut Cx, value: &Value) -> Result<Option<Value>>;
}
Expand description

How a guest language coerces values at number and string boundaries.

Required Methods§

Source

fn to_number(&self, cx: &mut Cx, value: &Value) -> Result<Option<Value>>

Convert value to a number value when this profile accepts such a coercion.

Source

fn to_string(&self, cx: &mut Cx, value: &Value) -> Result<Option<Value>>

Convert value to a string value when this profile accepts such a coercion.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§