]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #103394 - Pointerbender:unsafecell-docs, r=Amanieu
authorMatthias Krüger <matthias.krueger@famsik.de>
Thu, 27 Oct 2022 13:03:56 +0000 (15:03 +0200)
committerGitHub <noreply@github.com>
Thu, 27 Oct 2022 13:03:56 +0000 (15:03 +0200)
Clarify documentation about the memory layout of `UnsafeCell`

This PR addresses a [comment](https://github.com/rust-lang/rust/pull/101717#issuecomment-1279908390) by `@RalfJung` in PR #101717 to further clarify the documentation of `UnsafeCell<T>`. The previous PR was merged already before we had a chance to correct this, hence this second PR :)

To goal of this PR is:

1. Split the paragraph about the memory layout of `UnsafeCell<T>` and the usage of `UnsafeCell::(raw_)get()` into two paragraphs, so that it is easier to digest for the reader.
2. Slightly simplify the previously added examples in order to reduce redundancy between the new examples and the examples that already [existed](https://github.com/rust-lang/rust/blob/ddd119b2fed57eb6b19c44c18108de95c564a48d/library/core/src/cell.rs#L1858-L1908) before these 2 PRs (which remained untouched by both PRs).


Trivial merge