Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(marker/copy): provide example for &T being Copy #75049

Merged
merged 7 commits into from
Aug 19, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ pub trait StructuralEq {
/// the trait `Copy` may not be implemented for this type; field `points` does not implement `Copy`
/// ```
///
/// Shared references (`&T`) are also `Copy`, so a struct can be `Copy`, even when it holds
janriemer marked this conversation as resolved.
Show resolved Hide resolved
/// shared references of types `T` that are *not* `Copy`. Consider the following struct,
/// which can implement `Copy`, because it only holds a *shared reference* to our non-`Copy`
/// type `PointList` from above:
janriemer marked this conversation as resolved.
Show resolved Hide resolved
/// ```
/// # #![allow(dead_code)]
/// # struct PointList;
/// struct PointListWrapper<'a> {
janriemer marked this conversation as resolved.
Show resolved Hide resolved
/// point_list_ref: &'a PointList,
/// }
/// ```
///
/// ## When *can't* my type be `Copy`?
///
/// Some types can't be copied safely. For example, copying `&mut T` would create an aliased
Expand Down Expand Up @@ -540,7 +552,7 @@ macro_rules! impls {
/// For a more in-depth explanation of how to use `PhantomData<T>`, please see
/// [the Nomicon](../../nomicon/phantom-data.html).
///
/// # A ghastly note 👻👻👻
/// # A ghastly note
janriemer marked this conversation as resolved.
Show resolved Hide resolved
///
/// Though they both have scary names, `PhantomData` and 'phantom types' are
/// related, but not identical. A phantom type parameter is simply a type
Expand Down