News for hackers. Stuff that matters.
Re:Rust Ownership Rules by heeen2 on Monday March 02, 2020 @10:02AM (#22464940)
> If you have a class where this doesn't work (e.g. because it contains pointers into its own footprint)

When would you have pointers to a classes own memory instead of a named class member for the same data?

Re:Rust Ownership Rules by quietbritishjim on Monday March 02, 2020 @11:31AM (#22465846)
This can happen if you have one class that contains a pointer or reference to another class, and then you create a helper class that instantiates both of them as direct member variables.

Edit: Another example: Imagine you have a matrix class that contains a bit of memory as a char[] member to avoid heap allocation for small matrices. Then you maybe you want your data pointer to point directly at that data (rather than looking at a separate flag, which might cause an extra branch or just be more code complexity). I'm not saying it's a good idea, just it's obvious that it might come up.

Re:Rust Ownership Rules by rhn_mk1 on Monday March 02, 2020 @10:16AM (#22465046)
Linked lists, graphs. Granted, it's not the same structure, but it gets back there eventually.