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 | 
Beta Was this translation helpful? Give feedback.
-
| 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 | 
Beta Was this translation helpful? Give feedback.
-
| 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 
 | 
Beta Was this translation helpful? Give feedback.
-
| Can we think of any examples of  | 
Beta Was this translation helpful? Give feedback.
-
| 
 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  | 
Beta Was this translation helpful? Give feedback.
-
| In addition to #179 (comment), I've also used  So, yes, I like to use  | 
Beta Was this translation helpful? Give feedback.
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?Beta Was this translation helpful? Give feedback.
All reactions