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

Fallible conversion of the given value to a Ruby Integer or nil via #to_int.

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

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

§Errors

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