Open noamtashma opened 2 years ago
This repo has not received any commits for two years (since Feb 27, 2020) and seems unmaintained. Did you try to contact the owners directly?
Hey everyone, since so long has passed and still the maintainer hasn't showed up and no one made a replacement crate, I decided to make my pull request into a crate.
It's available as safer_owning_ref
.
I found more unsoundness problems. This extends #61 .
In particular,
OwningRef::map_with_owner
allows creating anOwningRef
that points at the owner, which can be moved.This by itself can be fixed by replacing
map_with_owner
with a method that only gives out a reference to the referent of the owner, like this:In addition, There's unsoundness combining a conversion from
OwningRefMut
toOwningRef
together with methods that can read the owner of anOwningRef
, like so:OwningRefMut::{as_owner, as_owner_mut}
can also be used, as #61 shows.There are two ways to fix this, and each choice corresponds to a small difference in the meaning and invariants of
OwningRef
:OwningRefMut
toOwningRef
, and allow shared access to the owner of anOwningRef
. Invariant: the reference of theOwningRef
may only borrow immutably from the owner.OwningRefMut
toOwningRef
, but disallow shared access to the owner of anOwningRef
. Invariant: the reference of theOwningRef
may borrow immutably or mutably from the owner.Essentially, these are two distinct types, which are both sound by themselves, and a third option is to have both types.