d-unsed / ruru

Native Ruby extensions written in Rust
MIT License
834 stars 40 forks source link

Remove all `unwrap()`s #8

Open steveklabnik opened 8 years ago

steveklabnik commented 8 years ago

As a long-term project, I would like to get rid of the unwraps and convert to Result<T, E>-based handling.

steveklabnik commented 8 years ago

So uh, I thought there were more, but there's only one, in str_to_cstring.

Still worth removing.

steveklabnik commented 8 years ago

This one is tough. Libraries shouldn't panic; but the situation in which this doesn't work is when a string has interior nulls, which shouldn't happen often. But still:

  1. "just don't pass a string with internal nulls" means unsafe, conceptually.
  2. "Make these things all return Result" is kinda bad, because well, it's such an edge case, and this would significantly reduce ergonomics.

So, I'm not sure how to tackle this one, exactly...