rust-lang / nomicon

The Dark Arts of Advanced and Unsafe Rust Programming
https://doc.rust-lang.org/nomicon/
Apache License 2.0
1.79k stars 261 forks source link

Add code example about how to write robust unsafe rust #270

Open Evian-Zhang opened 3 years ago

Evian-Zhang commented 3 years ago

From the Rustonomicon, we should write robust unsafe Rust against wrong-implemented safe Rust.

However, from the doc I only know why we should write robust unsafe Rust, but not how we should write it.

I looked into the source code of BTreeMap, but it is so complicated that I could not find the answer.

I posted this question in the forum, and we still could not get a clear code example.

JohnTitor commented 3 years ago

I think this topic is generally good to go to https://rust-lang.github.io/unsafe-code-guidelines/introduction.html. Though it may be a good idea to add a link to there.