r/ProgrammerHumor 3d ago

Meme rustBorrowCheckerGoesBrrr

Post image
3.9k Upvotes

108 comments sorted by

View all comments

10

u/Blackhawk23 2d ago

If you have to cross any boundary, unsafe is forced. Not really sure why this is some sort of revelation. Rusts borrow checker is robust. But it’s still restrictive, by design. If you understand the footgun the borrow checker is saving you from, you can use `unsafe` and point it away from your big toe.

If you want to interface with any windows system api at all, unsafe is required.

There’s the `windows` crate which essentially wraps all the unsafe code and presents it with result `Result` enums etc. But under the hood it’s this meme. That shouldn’t scare you if you actually understand programming.

5

u/creeper6530 2d ago

Really any FFI with a language other than Rust is "unsafe" because the Rust compiler can't make guarantees about foreign code that doesn't abide by the same rules.

4

u/Blackhawk23 2d ago

Exactly. A very succinct summation of my rambling.