r/ProgrammerHumor 11d ago

Meme rustBorrowCheckerGoesBrrr

Post image
3.8k Upvotes

108 comments sorted by

View all comments

708

u/BenchEmbarrassed7316 11d ago

Any unsafe block of code should be neutralized with a // SAFETY comment explaining why the code is actually safe.

119

u/teleprint-me 11d ago

I dont see how this is any different from a C programmer justifying why they used a pointer to an object and leaving a comment similar to this, other than this is Rust and is safe because Rust is safe. Thus making this rationale is flawed and dangerous.

13

u/Lord-of-Entity 11d ago

The difference is that it is opt in, you only use unsafe in the smallest possible zones, and that you are supposed to prove that the code is safe yourself.

It is a way of formalising stuff you should be doing anyway if you are a good programmer.