Kimundi / owning-ref-rs

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

Add OwningHandle::map #56

Closed arthurprs closed 2 months ago

arthurprs commented 4 years ago

This can be used to convert a RAII guard, for example. In my use-case I'm downgrading a Write guard to a Read guard.

AFAIK this doesn't need to be unsafe as it can rely on the safety of the previously built handle.

yvt commented 2 years ago

IIUC this is unsound because it would expose H, which might have a false lifetime (e.g., RefMut<'static, _>), to safe code.