Re:Rust 2024 the Year of Everywhere?
by rascul on Thursday September 22, 2022 @11:14PM
(#32947593)
What syntax is different with unsafe?
[ Parent
| on HN ]
Re:Rust 2024 the Year of Everywhere?
by woodruffw on Thursday September 22, 2022 @11:21PM
(#32947634)
Unsafe Rust's syntax is a superset of Safe Rust, meaning that there is syntax in Unsafe Rust that will not compile in Safe Rust[1].
[1]: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
It's the same syntax. There are no special operators in unsafe rust. All unsafe code is syntactically valid safe code. The reason it will not compile it because certain operations are not permitted, not because of syntax errors
That doc needs to be rewritten. By that logic, closure Rust is another subset, and Iterator, so are pub (crate) modifiers, etc.
It just allows access to: raw pointers, unsafe fields and methods, and unsafe traits.