Function artichoke_backend::convert::maybe_to_int

source ·
pub fn maybe_to_int(
    interp: &mut Artichoke,
    value: Value
) -> Result<MaybeToInt, Error>
Expand description

Attempt a fallible conversion of the given value to i64.

Conversion steps:

  • If the given value is an Integer, return its underlying i64.
  • If the value does not have a to_int method, the conversion is not applicable so return None.
  • If value.to_int raises, return the exception in Err(_).
  • If the value returned by the conversion is an Integer, return its underlying i64.
  • Else, the conversion is not applicable so return None.