Skip to content

Tracking Issue for pin_deref_mut #86918

@jonhoo

Description

@jonhoo
Contributor

Feature gate: #![feature(pin_deref_mut)]

This is a tracking issue for Pin::as_deref_mut.

The feature adds the method as_deref_mut to Pin, which allow a safe transformation from a Pin<&mut Pin<P>> to a Pin<&mut P::Target>.

Public API

impl<Ptr> Pin<Ptr> {
    pub fn as_deref_mut(self: Pin<&mut Pin<Ptr>>) -> Pin<&mut Ptr::Target>
    where
        Ptr: DerefMut;
}

Steps / History

Unresolved Questions

  • None yet.

Activity

added
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
on Jul 6, 2021
RalfJung

RalfJung commented on Nov 7, 2022

@RalfJung
jonhoo

jonhoo commented on Nov 7, 2022

@jonhoo
Author
coolreader18

coolreader18 commented on Nov 16, 2023

@coolreader18
Contributor

Are there any remaining blockers on this? It's a pretty useful function for blanket impls for traits with poll methods (e.g. Future already uses it in its impl<P> Future for Pin<P> impl).

jonhoo

jonhoo commented on Nov 18, 2023

@jonhoo
ContributorAuthor

Not that I know of — given it touches the Pin machinery, I suspect it should go through an actual FCP, but I'll let others be the judge of that :)

dtolnay

dtolnay commented on Jun 25, 2024

@dtolnay
Member

Currently this method is located in its own solitary impl block:

impl<'a, Ptr: DerefMut> Pin<&'a mut Pin<Ptr>> {
    pub fn as_deref_mut(self) -> Pin<&'a mut Ptr::Target>;
}

I'd like to consider changing it to:

impl<Ptr> Pin<Ptr> {
    pub fn as_deref_mut(self: Pin<&mut Pin<Ptr>>) -> Pin<&mut Ptr::Target>
    where
        Ptr: DerefMut;
}

Some advantages:

  • Synergy with the existing as_ref and as_mut signatures (stable since Rust 1.33)
  • Lifetime elision reduces noise in the signature
  • Turbofish less verbose: Pin::<&mut T>::as_deref_mut vs Pin::<&mut Pin<&mut T>>::as_deref_mut
impl<Ptr> Pin<Ptr> {
    pub fn as_ref(&self) -> Pin<&Ptr::Target>
    where
        Ptr: Deref;

    pub fn as_mut(&mut self) -> Pin<&mut Ptr::Target>
    where
        Ptr: DerefMut;
}
thynson

thynson commented on Jul 11, 2024

@thynson

Any concern blocks this from stablization?

jonhoo

jonhoo commented on Jul 15, 2024

@jonhoo
ContributorAuthor

@dtolnay I agree — that is better 👍

added a commit that references this issue on Aug 24, 2024
f45ce8d

29 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: 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.disposition-mergeThis 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @jonhoo@RalfJung@thynson@dtolnay@apiraino

      Issue actions

        Tracking Issue for `pin_deref_mut` · Issue #86918 · rust-lang/rust