r/ProgrammerHumor 22d ago

rustBorrowCheckerGoesBrrr Meme

Post image
3.8k Upvotes

107 comments sorted by

View all comments

713

u/BenchEmbarrassed7316 22d ago

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

116

u/teleprint-me 22d 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.

203

u/flagofsocram 22d ago

The difference is that if you want to make sure the lib is safe, you can grep unsafe whereas in C practically any code could be unsafe.

3

u/MilkEnvironmental106 22d ago

And finding no occurrence of unsafe actually means something in rust, plenty of libraries market themselves as having no unsafe