3 ms·
Only if you use unsafe and even then three are restrictions. The general idea of rust is that it will only let you do things it can verify are safe otherwise it
by edude03 3y ago
Only if you use unsafe and even then three are restrictions. The general idea of rust is that it will only let you do things it can verify are safe otherwise it won't compile.
- insanitybit 3y ago> Only if you use unsafe and even then three are restrictions. I can't think of any. The borrow checker still checks your code but you can forge, twiddle, and cast pointers, there's really nothing you can't do that I can think of.
- edude03 3y agoFrom https://github.com/itfanr/rust-doc-en/blob/master/unsafe.md#unsafe-superpowers https://github.com/itfanr/rust-doc-en/blob/master/unsafe.md#... > In both unsafe functions and unsafe blocks, Rust will let you do three things that you normally can not do. Just three. Here they are: > Access or update a static mutable variable. Dereference a raw pointer. Call unsafe functions. This is the most powerful ability. That’s it. It’s important that unsafe does not, for example, ‘turn off the borrow checker’. Adding unsafe to some random Rust code doesn’t change its semantics, it won’t start accepting anything. But it will let you write things that do break some of the rules.
- insanitybit 3y agoThat doesn't change anything I said. Those unsafe functions include things like casting pointers. There's nothing you can't do through some composition of those 3 things.