Borrow Checker

dukk@programming.dev to Programmer Humor@programming.dev – 126 points –
12

You are viewing a single comment

Just add unsafe sheesh.

best solution to all rust problems /s

This might be the wrong place for this question, but I have heard criticism that real rust programs contain lots of unsafe code. Is this true?

Define what makes a rust program "real" lol.

Any kind of library that does a lot of low-level stuff (kernel syscalls, custom binary reprs, ffi) will have to use unsafe. But most applications built using these libraries rarely need to use unsafe at all, because the libraries act as safe wrappers to make sure the app developer isn't accidentally violating invariants allowed by the "unsafe" keyword.

Yeah. For example Lemmy backend is written purely in Rust and doesn’t use unsafe anywhere, but some lower-level library it uses probably does use unsafe for IO code.