|
|
|
|
|
by kibwen
3298 days ago
|
|
> It would be neat if we could decompose unsafe like so "unsafe[this_feature,that_feature] {}" I sometimes feel the same way, but remember that the `unsafe` keyword only unlocks four additional features: 1. Dereferencing a raw pointer 2. Calling an unsafe function or method 3. Accessing or modifying a mutable static variable (and this might conceivably even be removed entirely someday) 4. Implementing an unsafe trait It's unclear to me how to make this any more fine-grained such that annotating the "kind" of unsafe you're using would be useful and enforceable by the compiler (which is crucial, because otherwise why not just use a comment?). In practice I think really the only "distinction" in unsafe Rust that I want is the ability to distinguish unsafe blocks that exist only to call external C code. |
|
Mutable static variables removed or the unsafety of accessing them? Didn't Rust, at one early point, not allow mutable global variables?