You would obviously need a HRTB callback for soundness, not like this where the caller can choose the lifetime. This capability is a lot like owning_ref::RcRef
, though I don't really like that crate at the moment because of the high number of unfixed soundness issues. Actually.. reading through my very own open issue there, I think that even a simple change to HRTB callback in the API above might still leave the same soundness issue as owning_ref#71; and possibly an approach like owning_ref#72 might be necessary, so the type becomes something like ProjectedRc<'a, T, A: 'a>
(where T
is the target type of the original underlying Arc
). And now I need to double-check if/why lock_api::MappedRwLockReadGuard
doesn't have the same issue... Edit: Ah, it's because that type has a lifetime parameter, too!