3 ms·
In Java, you can hold onto a reference to the UserAccount directly, for as long as you want. The borrow checker, however, forces you to hold onto an index inst
by verdagon 4y ago
In Java, you can hold onto a reference to the UserAccount directly, for as long as you want.
The borrow checker, however, forces you to hold onto an index instead.
- anonymoushn 4y agoRight, it sounds like you are circumventing the borrow checker and then experiencing some of the classes of bugs it was supposed to prevent. And this seems common: https://www.youtube.com/watch?v=4t1K66dMhWk https://www.youtube.com/watch?v=4t1K66dMhWk
- verdagon 4y ago> Circumventing the borrow checker Programs often require inherent state with data that refers to other data. In these cases, one must circumvent the borrow checker, whether it be with indices, IDs, Rc, or whatever. The borrow checker simply does not allow changing data when someone has a reference to it (except for the rare case where we can use Cell). It's a myth that we can rewrite any program to not circumvent the borrow checker.