Hi, learning raw pointers I stumbled over raw pointer cleanup pre-RFC by @Gankra
What could this possibly mean?
*mut T is invariant over T
My aim is just to understand Rust better
Thx,
Hi, learning raw pointers I stumbled over raw pointer cleanup pre-RFC by @Gankra
What could this possibly mean?
*mut T is invariant over T
My aim is just to understand Rust better
Thx,
I don't understand much, but the nomicon has a section on this:
That section is basically my best explanation on the topic.
Variance honestly doesn't matter too much as far as I can tell, but it does make some things easier to deal with. All that it really does is allow you to pass long-lived things where a short-lived thing was expected. (Perhaps) surprisingly this isn't always sound to do, as the nomicon goes into detail (with mutability it can let you give a short-lived thing to someone who thought they had a long-lived thing).