• 0 Posts
  • 12 Comments
Joined 1 year ago
cake
Cake day: June 15th, 2023

help-circle


  • Vim or emacs? I mean I know they were created a long time ago, but they are both pretty good pieces of software, both highly configurable. I don’t understand people aversion to them, rather than having the false belief that they are too complicated? When in reality they just aren’t intuitive in terms of modern stuff. But they aren’t difficult, just different.










  • Eh, if by smart pointer you mean Pin. It’s not really a smart pointer. It’s just a struct that holds onto a particular reference kind. What it holds onto can be a smart pointer, or a mutable reference. Either way, once done, the constraints of the language’s ownership and borrowing mean the item that has been Pinned can’t be moved.

    An item being unable to be moved is pretty important for self referential structures of course, since to self reference, you generally refer to something by some form of pointer inside yourself. If you are able to be moved, your own root address changes and thus the address of anything inside you would be different, which would invalidate your self references.

    Pin was quite a clever realization.

    However, unfortunately, not all considerations you need to be aware of when using Pin can be enforced by the type system, usually around when you need to Unpin something. And you get that wrong you might end up in a place that would cause Undefined Behavior. Which is why the general advice is, once you’ve Pinned something, it should stay Pinned.