Function artichoke_backend::convert::to_str

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

Fallible conversion of the given value to a Ruby String via #to_str.

If the given value is a string, it is returned. If the give value responds to a #to_str 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 String.

§Errors

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