matklad / once_cell

Rust library for single assignment cells and lazy statics without macros
Apache License 2.0
1.87k stars 109 forks source link

Explain safety of `unsync::OnceCell::get(&self)` in more detail #214

Closed Enselic closed 1 year ago

Enselic commented 1 year ago

Background: I'm working on improving my unsafe Rust skills, and figuring out how once_cell works is one way to do that. By more elaborately explaining why unsync::OnceCell::get(&self) is safely implemented, I hope to help others increase their understanding of unsafe Rust as well.

(It was not obvious to me at first why unsync::OnceCell::get(&self) was safe. But I think I figured it out now.)

matklad commented 1 year ago

bors r+

Thanks!

bors[bot] commented 1 year ago

Build succeeded!

And happy new year! 🎉