diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-01 17:10:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-01 17:10:25 +0200 |
| commit | 15eebac9d962fa7510f4729f85e57c46a39c3ea1 (patch) | |
| tree | db6b36a40edc4747d1157feb89657f322e44f167 | |
| parent | 02134611cefa7c0d45503c91375653af216a40bc (diff) | |
| parent | 09c50a0ae309dab351cb6c4d0f570a57ea72a7e9 (diff) | |
| download | rust-15eebac9d962fa7510f4729f85e57c46a39c3ea1.tar.gz rust-15eebac9d962fa7510f4729f85e57c46a39c3ea1.zip | |
Rollup merge of #111065 - est31:send_mut_ref, r=m-ou-se
Explicitly document how Send and Sync relate to references Some of these relations were already mentioned in the text, but that Send is implemented for &mut impl Send was not mentioned, neither did the docs list when &T is Sync. Inspired by the discussion in #110961. [Proof](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ed77bfc3c77ba664400ebc2734f500e6) based on `@lukas-code` 's [example](https://github.com/rust-lang/rust/pull/110961#discussion_r1181220662).
| -rw-r--r-- | library/core/src/marker.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 40789cb3049..82e4c648974 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -24,7 +24,7 @@ use crate::hash::Hasher; /// operations. Its cousin [`sync::Arc`][arc] does use atomic operations (incurring /// some overhead) and thus is `Send`. /// -/// See [the Nomicon](../../nomicon/send-and-sync.html) for more details. +/// See [the Nomicon](../../nomicon/send-and-sync.html) and the [`Sync`] trait for more details. /// /// [`Rc`]: ../../std/rc/struct.Rc.html /// [arc]: ../../std/sync/struct.Arc.html @@ -426,6 +426,11 @@ pub macro Copy($item:item) { /// becomes read-only, as if it were a `& &T`. Hence there is no risk /// of a data race. /// +/// A shorter overview of how [`Sync`] and [`Send`] relate to referencing: +/// * `&T` is [`Send`] if and only if `T` is [`Sync`] +/// * `&mut T` is [`Send`] if and only if `T` is [`Send`] +/// * `&T` and `&mut T` are [`Sync`] if and only if `T` is [`Sync`] +/// /// Types that are not `Sync` are those that have "interior /// mutability" in a non-thread-safe form, such as [`Cell`][cell] /// and [`RefCell`][refcell]. These types allow for mutation of |
