owning-ref-rs
owning-ref-rs copied to clipboard
Possible approach to fix #71
Resolves #71.
Only a draft since this does not explain the lifetime parameter in the documentation and since it isn’t clear whether an alternative solution with
pub struct OwningRef_<'t, O, T: ?Sized> {
owner: O,
reference: *const T,
marker: PhantomData<&'t T>,
}
type OwningRef<O, T: ?Sized> = OwningRef_<'static, O, T>;
would be better (e.g. to reduce breakage). This would, effectlively, be like restricting OwningRef<O, T: ?Sized>
to T: 'static
(while also providing a more general version).
And it’s not clear what the best choice for more vs. less lifetime parameters for all the type synonyms is. This PR so far took the approach of avoiding implicit 'static
s, but also avoiding confusion by having multiple type parameters for e.g. RefRef
. Note that the type synonyms are for the common case only, so having them be somewhat restricted w.r.t. lifetimes would still allow people to use the underlying OwningRef
/OwningRef_
-based explicit type—with all the lifetimes—anyways.