Clarify role of unsafe functions #179
Replies: 6 comments
|
Hints towards API invariants:
https://doc.rust-lang.org/book/second-edition/ch19-01-unsafe-rust.html |
|
Hints towards undefined behavior:
https://doc.rust-lang.org/nomicon/what-unsafe-does.html
https://doc.rust-lang.org/book/second-edition/ch19-01-unsafe-rust.html |
|
An example of a way to break invariants of an API that doesn't result in UB, and as such is explicitly not marked as unsafe: https://doc.rust-lang.org/std/collections/hash_map/struct.HashMap.html
|
|
Can we think of any examples of |
I missed the "in the ecosystem" part of your question. While I don't know of an existing use, this came up because of crate-ci/escargot#6 where I am concerned about the brittleness of some functions and am considering marking them I do see value in other cases. For example, I remember a |
|
In addition to #179 (comment), I've also used So, yes, I like to use |
Uh oh!
There was an error while loading. Please reload this page.
The only things the guidelines say about
unsafefunctions are:Should
unsafebe reserved for compiler Undefined Behavior or also bypassing API invariant checks?All reactions