logoalt Hacker News

Ar-Curuniryesterday at 8:57 PM1 replyview on HN

Almost all uses of unsafe in Rust are either for FFI, or to avoid the overhead of things like ref-counting. If you use, eg, Rc RefCell everywhere you will achieve safety without issue.


Replies

pizlonatoryesterday at 9:42 PM

> Almost all uses of unsafe in Rust are either for FFI

Which makes Rust less safe than Fil-C.

Consider that you have a dependency like libc, PAM, openssl, or the like.

In Rust: you will `unsafe` call into the unsafe versions of those libraries. Hence, even if your Rust code is safe in isolation, your program is not safe overall because you're pulling in unsafe code.

In Fil-C: compile those dependencies with Fil-C, and then the whole process is safe.

show 1 reply