Skip to content
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

Add T: ?Sized to the From<Box<T>> impl for Pin<Box<T>> #56256

Closed
DutchGhost opened this issue Nov 26, 2018 · 1 comment · Fixed by #57313
Closed

Add T: ?Sized to the From<Box<T>> impl for Pin<Box<T>> #56256

DutchGhost opened this issue Nov 26, 2018 · 1 comment · Fixed by #57313

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Nov 26, 2018

Currently, the implementation for From<Box<T>> for Pin<Box<T>> is defined as:

impl<T> From<Box<T>> for Pin<Box<T>>

https://doc.rust-lang.org/nightly/std/pin/struct.Pin.html#impl-From%3CBox%3CT%3E%3E

This does not allow trait objects to be pinned. It is however possible to call Box::pinned, and convert that into a trait object.

Is it intentional that T is required to be Sized on the From implementation?

Defining it as this:

impl<T: ?Sized> From<Box<T>> for Pin<Box<T>>

allows to call Pin::from(trait_object)

@cramertj
Copy link
Member

cramertj commented Nov 28, 2018

Is it intentional that T is required to be Sized on the From implementation?

nope, and I'd happily r+ a PR fixing this, Arc, and Rc as well

kennytm added a commit to kennytm/rust that referenced this issue Jan 5, 2019
Improve Box<T> -> Pin<Box<T>> conversion

I found the `From` trait conversion for this very hard to find, having a named function for it is much more discoverable. Also fixes rust-lang#56256 as I need that in the place I'm using this.

Has a placeholder tracking issue, will file an issue once I get feedback.
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 a pull request may close this issue.

2 participants