Skip to content

provide project method on &mut Pin<&mut Self> #345

@ijackson

Description

@ijackson

AFAICT it is not possible, given a function which takes Pin<&mut Sefl>, to make two function calls in turn which take Pin<&mut Self>. This is because the borrow checker's special logic for permitting this for &mut Self does not apply to Pin<&mut Self>.

I think it would be possible to solve this problem if pin_project provided something like this:

    fn project_mut(self: &mut Pin<&mut Self>) -> ....

It seems that this was previously done, but this was changed in #89. Obviously I'm not suggesting it ought to be changed back. But I don't see any reason why it wouldn't be sensible to provide both. I think this should be sound because the outer &mut guarantees unique ownership of the inner &mut.

Would you welcome a MR to provide this other method, perhaps optionally?

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a538875119bf28650f67540fe94a440f

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-questionCategory: A question

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions