I’ve thorougly read Pin’s documentation and few articles about it. I have no questions about Pin and why does it matter. Except one: Why Pin must hold a pointer? Why it is unable to keep data directly (e.g. own it)?
Maybe, such decision was made because Pin exists only at compile time?
>Solution :
Every type in Rust is trivially movable, so if you have a value of that type in a variable and there are no active borrows, you can always move it into a different location.
The whole point of Pin is that the data it refers to is "pinned" to a specific location, making that value unmovable (unless the pinned type implements Unpin). However, Pin itself is a movable type, just like any other type, so as long as it’s not borrowed you can move it around freely.
What happens if Pin directly contains the pinned data instead of using a reference? Then moving the Pin around would also move around all of its fields, including the pinned data it contains, which would obviously break the pinning guarantees of the type.
Because of this, Pin can’t contain the pinned data correctly, and it can only work with pointer types that don’t move around the data being pointed to, especially when the pointers themselves are moved (which includes standard pointer types like &T, &mut T, Box<T>, Rc<T>, etc.).