artichoke_backend::convert

Function to_i

Source
pub fn to_i(interp: &mut Artichoke, value: Value) -> Result<Value, Error>
Expand description

Fallible coercion of the given value to a Ruby Integer via #to_i.

If the given value is an integer, it is returned. If the give value responds to a #to_i method, it is called. Otherwise, a TypeError is raised.

If this function returns Ok, the returned Value is guaranteed to be a non-nil Ruby Integer.

ยงErrors

  • If the call to #to_i returns an error, that error is returned.
  • If the call to #to_i returns anything other than a Integer, a TypeError is returned.