Skip to content

Instantly share code, notes, and snippets.

@amachang
Last active February 19, 2024 18:38
Show Gist options
  • Save amachang/7b2b41e8eb7b708097ed192f4add9ede to your computer and use it in GitHub Desktop.
Save amachang/7b2b41e8eb7b708097ed192f4add9ede to your computer and use it in GitHub Desktop.
Rust の Pin がまたわからなくなった

Rust の Pin 時々細かい部分を忘れるので、それ用の gist を作って書き足しておく

Pin されたら move できなくなるというけど、 return (Pin<T> の値); とかしたら move されない??

試してないけど、型を見る限り多分 move される。

基本的にこの疑問は前提が間違っていて、 Pin は Box とか &mut とか Smart pointer 、参照、ポインタに対して使われるものなので、 Pin<T> が move されてもポインタが move されるだけで自己参照構造体自体は壊れない

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