Skip to content

Allow going from UniquePtr<T> to Pin<UniquePtr<T>> #1358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

tbu-
Copy link

@tbu- tbu- commented Jul 2, 2024

This is safe since there cannot be any other references to the interior T and because the Deref/DerefMut implementations are sane.

This is safe since there cannot be any other references to the interior
`T` and because the `Deref`/`DerefMut` implementations are sane.
Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a T which is not Unpin, cxx's UniquePtr<T> already enforces that safe code cannot move T. Can you explain more about the use case for needing Pin<UniquePtr<T>>? It doesn't have any invariant that is different from UniquePtr<T>.

@tbu-
Copy link
Author

tbu- commented Jul 3, 2024

You're correct. I didn't see that the pin_mut function already lets me go from a UniquePtr<T> to a Pin<&mut T>. This PR is unneeded. Sorry and thanks for the quick answer.

@tbu- tbu- closed this Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants