3 ms·
Writing code without the borrow checker is the same as writing code with the borrow checker. If it wouldn't pass the borrow checker, you're doing something wron
by ycombinatrix 8mo ago
Writing code without the borrow checker is the same as writing code with the borrow checker. If it wouldn't pass the borrow checker, you're doing something wrong.
- drivebyhooting 8mo agoCome on that’s not true. How would you write and LRU cache in rust? It’s not possible in idiomatic rust. You either need to use unsafe or use integer indices as a poor man’s pointer.
- ycombinatrix 8mo agoWhat's wrong with integer indices? They have bounds checking. You definitely do not need unsafe to do LRU.
- mattgreenrocks 8mo agoIndices are fine. Fixating on the “right” shape of the solution is your hang-up here. Different languages want different things. Fighting them never ends well.
- srcreigh 8mo agoIdk. Did you see the "Buffer reuse" section of this blog post? [1] Kudos to that guy for solving the puzzle, but I really don't want to use a special trick to get the compiler to let me reuse a buffer in a for loop. [1]: https://davidlattimore.github.io/posts/2025/09/02/rustforge-wild-performance-tricks.html https://davidlattimore.github.io/posts/2025/09/02/rustforge-...
- ycombinatrix 8mo agoI've never seen `split_off_mut` but I do use `split_at_mut` quite often to solve similar issues. Using a slice instead of using a Vec directly also tends to greatly simplify things. I also don't fully understand the buffer reuse example. Why would you want to store references to a string after the string ceases to exist?
- forrestthewoods 8mo agoThis is a n objectively false statement. Rusts borrow checker is only able to prove at compile-time that a subset of correct programs are correct. There are many correct programs that the BC is unable to prove to be correct and therefore rejects them. I’m a big fan of Rust and the BC. But let’s not twist reality here.
- lmm 8mo ago> There are many correct programs that the BC is unable to prove to be correct and therefore rejects them. There are programs that "work" but the reason they "work" is complicated enough that the BC is unable to understand it. But such programs tend to be difficult for human readers to understand too, and usually unnecessarily so.
- ycombinatrix 8mo ago>There are many correct programs that the BC is unable to prove to be correct and therefore rejects them. No. The borrow checker rejects programs that are definitely incorrect. It does not require that the program is correct. That's a big difference.
- ChadNauseam 8mo agothere’s a miscommunication. programs that pass the borrow checker all are memory safe (assuming code marked unsafe is sound). This means that all memory unsafe programs are excluded. but some memory-safe programs are excluded too.
- forrestthewoods 8mo agoNo. The BC will not incorrectly approve an incorrect program. But the BC does not approve all correct programs. Because some patterns which are indeed perfectly correct and will never explode the BC is not able to prove that and therefore the BC rejects the program. The BC is effectively incompatible with typical video game patterns. The whole level/frame life cycle is effectively unsupported by the Rust BC. As just one example.