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 underlyingi64
. - If the value does not have a
to_int
method, the conversion is not applicable so returnNone
. - If
value.to_int
raises, return the exception inErr(_)
. - If the value returned by the conversion is an
Integer
, return its underlyingi64
. - Else, the conversion is not applicable so return
None
.