-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking issue for {Rc, Arc}::get_mut_unchecked #63292
Copy link
Copy link
Open
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 RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
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 RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Type
Fields
Give feedbackNo fields configured for issues without a type.
On
RcandArcan new unsafeget_mut_uncheckedmethod provides&mut Taccess without checking the reference count.Arc::get_mutinvolves multiple atomic operations whose cost can be non-trivial.Rc::get_mutis less costly, but we addRc::get_mut_uncheckedanyway for symmetry withArc.These can be useful independently, but they will presumably be typical when uninitialized constructors (tracked in #63291) are used.
An alternative with a safe API would be to introduce
UniqueRcandUniqueArctypes that have the same memory layout asRcandArc(and so zero-cost conversion to them) but are guaranteed to have only one reference. But introducing entire new types feels “heavier” than new constructors on existing types, and initialization ofMaybeUninit<T>typically requires unsafe code anyway.PR #62451 adds:
Open questions / issues
get_unchecked_mutto match https://doc.rust-lang.org/std/?search=get_unchecked_mut ?