-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking issue for Weak::into_raw/from_raw & similar #60728
Copy link
Copy link
Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Changing this to a tracking issue for the feature:
Weak::new()) andT: ?Sized? These seem to be incompatible.The original proposal
Hello
The Arc has the
into_rawandfrom_rawmethods. I think it would be technically possible to have the same onWeak. Obviously, asWeakis non-owning, it would be up to the caller to make sure the pointer is not dangling when used.Would adding these (and maybe
as_rawtoo ‒ one can get a reference out ofArc, but not fromWeak) require an RFC, because the handling of these methods might be even a bit more delicate than the ones onArc, or is this considered small enough for just a pull request & later stabilization?Motivation
I've written the arc-swap crate that allows to keep an Arc around but make it point to some other object atomically. It uses the mentioned methods. It would make sense to have weak version of this atomic storage too.
Additionally, the
as_rawwould make it possible to compare if eg anArcandWeakpoint to the same object (which would also come handy in some alternative of theCachethat doesn't hold the object alive needlessly).