in rust is it possible to write an impl for a type only if it's wrapped in Rc?
-
Show this thread
-
Replying to @mountain_ghosts
Hm? You can `impl MyTrait for Rc<MyType>`. Also, `fn function(self: Rc<Self>,...)` effectively does constrain the implementation, though I dislike the ergonomics of it.
1 reply 0 retweets 0 likes -
Replying to @Argorak
ah, did not realise you could set the self type like that
1 reply 0 retweets 1 like -
Replying to @mountain_ghosts
It's a new an rare feature, needed for Futures (they are (self: Pin<&mut Self>, ...)
1 reply 0 retweets 2 likes -
-
Replying to @mountain_ghosts @Argorak
and in the absence of this feature, what you do in my case? is Future similar, i.e. you want to pass a future to many callers to bind its value without consuming it?
2 replies 0 retweets 0 likes
I believe the answer is "no" to your last question. The reason why Pin exists in the Futures type is to guarantee it doesn't move in memory, thus ensuring pointers aren't invalidated (esp useful if a struct points to itself — moving it in memory would break the pointer)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.