Skip to content

Commit 22bc720

Browse files
committed
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.
1 parent 19b500b commit 22bc720

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/marker.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::hash::Hasher;
2424
/// operations. Its cousin [`sync::Arc`][arc] does use atomic operations (incurring
2525
/// some overhead) and thus is `Send`.
2626
///
27-
/// See [the Nomicon](../../nomicon/send-and-sync.html) for more details.
27+
/// See [the Nomicon](../../nomicon/send-and-sync.html) and the [`Sync`] trait for more details.
2828
///
2929
/// [`Rc`]: ../../std/rc/struct.Rc.html
3030
/// [arc]: ../../std/sync/struct.Arc.html
@@ -426,6 +426,11 @@ pub macro Copy($item:item) {
426426
/// becomes read-only, as if it were a `& &T`. Hence there is no risk
427427
/// of a data race.
428428
///
429+
/// A shorter overview of how [`Sync`] and [`Send`] relate to referencing:
430+
/// * `&T` is [`Send`] if and only if `T` is [`Sync`]
431+
/// * `&mut T` is [`Send`] if and only if `T` is [`Send`]
432+
/// * `&T` and `&mut T` are [`Sync`] if and only if `T` is [`Sync`]
433+
///
429434
/// Types that are not `Sync` are those that have "interior
430435
/// mutability" in a non-thread-safe form, such as [`Cell`][cell]
431436
/// and [`RefCell`][refcell]. These types allow for mutation of

0 commit comments

Comments
 (0)