▲ | skulk 6 days ago | |||||||||||||||||||||||||||||||||||||||||||
This is a very tempting and commonly used strategy in Rust to bypass the borrow checker. I've used it to implement tries/DFAs with great success (though I can't find the code anymore) | ||||||||||||||||||||||||||||||||||||||||||||
▲ | Animats 5 days ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||
The trouble is, you've just replicated the problems of raw pointers. You can have dangling indices if the underlying object is reused or cleared. You can have aliasing, with two indices to the same object. It's a problem in practice. Of the three times I've ever had to use a debugger on Rust code, two came from code someone had written to do their own index allocation. They'd created a race condition that Rust would ordinary prevent. | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||
▲ | skeezyboy 5 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||
> This is a very tempting and commonly used strategy in Rust to bypass the borrow checker. Are you even allowed to publicly disparage the borrow checker like that? | ||||||||||||||||||||||||||||||||||||||||||||
▲ | bombela 5 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||
You don't bypass the borrow checker. Instead you use it the way it wants to be used. | ||||||||||||||||||||||||||||||||||||||||||||
|