[][src]Trait artichoke::prelude::CoerceToNumeric

pub trait CoerceToNumeric {
    type Value: Value;
    type Float;
    type Error;
    pub fn coerce_to_float(
        &mut self,
        value: Self::Value
    ) -> Result<Self::Float, Self::Error>; }

Coerce Ruby values to native numerics (floats and integers).

Associated Types

type Value: Value[src]

Concrete type of boxed Ruby value as inputs to coerce functions.

type Float[src]

Concrete float type to coerce values into, e.g. f64.

type Error[src]

Concrete error type for errors encountered when coercing values.

Loading content...

Required methods

pub fn coerce_to_float(
    &mut self,
    value: Self::Value
) -> Result<Self::Float, Self::Error>
[src]

Coerce the given Ruby value to a Float.

This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator.

See Numeric#coerce.

Errors

If a Ruby nil is given, an error is returned.

If the given value does not subclass Numeric, an error is returned.

If the Numeric class is not defined, an error is returned.

If the underlying interpreter returns an error when calling #to_f or Numeric#coerce, the error is returned.

Loading content...

Implementors

impl CoerceToNumeric for Artichoke[src]

type Value = Value

type Float = f64

type Error = Error

Loading content...