Fix missing const for inherent pointer replace
methods
#136877
+4
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ptr::replace
(the free fn) is already const stable. However, there are inherent convenience methods on*mut T
andNonNull<T>
, allowing you to write eg.unsafe { foo.replace(bar) }
wherefoo
is*mut T
orNonNull<T>
.It seems const was never added to the inherent method (likely oversight), so this PR adds it.
I don't believe this needs another1 FCP as the inherent methods are already stable and
ptr::replace
is already const stable, so this adds no new API.Original tracking issue: #83164
ptr::replace
constified in #83091ptr::replace
const stabilized in #130954Footnotes
const_replace
FCP completed: https://github.com/rust-lang/rust/issues/83164#issuecomment-2385670050 ↩