Kimundi / owning-ref-rs

A library for creating references that carry their owner with them.
MIT License
359 stars 50 forks source link

`OwningHandle::new` should allow handle to propagate errors. #19

Closed jonhoo closed 7 years ago

jonhoo commented 7 years ago

If the operation creating the handle fails for some reason, exposing that error is currently quite difficult. Could the signature of new perhaps be changed to

fn new<F, E>(o: O, f: F) -> Result<Self, E>
  where F: Fn(*const O::Target) -> Result<H, E> {}
Kimundi commented 7 years ago

Sounds reasonable! Instead of changing new, I added an try_new() constructor though.

Check it out on master and tell me if its the expected semantic. :)

jonhoo commented 7 years ago

try_new seems perfect!