Skip to content

Commit fc467b3

Browse files
committed
Reorder Copy doc sections
The new order puts all the "when" questions together and puts the "how" question with the "derivable" section. So you have to scroll past (and hopefully read) the can/cannot/should caveats and guidelines to get to the information about how to actually go about doing it once you've determined that you can and should, with derivable information first so that you can just use the derived implementation if that applies. Previous order: * General explanation * When can my type be `Copy`? * How can I implement `Copy`? * When can my type _not_ be `Copy`? * When should my type be `Copy`? * Derivable New order: * General explanation * When can my type be `Copy`? * When can my type _not_ be `Copy`? * When should my type be `Copy`? * Derivable * How can I implement `Copy`?
1 parent 2f44053 commit fc467b3

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/libcore/marker.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -136,26 +136,6 @@ pub trait Unsize<T: ?Sized> {
136136
/// the trait `Copy` may not be implemented for this type; field `points` does not implement `Copy`
137137
/// ```
138138
///
139-
/// ## How can I implement `Copy`?
140-
///
141-
/// There are two ways to implement `Copy` on your type:
142-
///
143-
/// ```
144-
/// #[derive(Copy, Clone)]
145-
/// struct MyStruct;
146-
/// ```
147-
///
148-
/// and
149-
///
150-
/// ```
151-
/// struct MyStruct;
152-
/// impl Copy for MyStruct {}
153-
/// impl Clone for MyStruct { fn clone(&self) -> MyStruct { *self } }
154-
/// ```
155-
///
156-
/// There is a small difference between the two: the `derive` strategy will also place a `Copy`
157-
/// bound on type parameters, which isn't always desired.
158-
///
159139
/// ## When can my type _not_ be `Copy`?
160140
///
161141
/// Some types can't be copied safely. For example, copying `&mut T` would create an aliased
@@ -175,6 +155,26 @@ pub trait Unsize<T: ?Sized> {
175155
///
176156
/// This trait can be used with `#[derive]` if all of its components implement `Copy` and the type
177157
/// implements `Clone`. The implementation will copy the bytes of each field using `memcpy`.
158+
///
159+
/// ## How can I implement `Copy`?
160+
///
161+
/// There are two ways to implement `Copy` on your type:
162+
///
163+
/// ```
164+
/// #[derive(Copy, Clone)]
165+
/// struct MyStruct;
166+
/// ```
167+
///
168+
/// and
169+
///
170+
/// ```
171+
/// struct MyStruct;
172+
/// impl Copy for MyStruct {}
173+
/// impl Clone for MyStruct { fn clone(&self) -> MyStruct { *self } }
174+
/// ```
175+
///
176+
/// There is a small difference between the two: the `derive` strategy will also place a `Copy`
177+
/// bound on type parameters, which isn't always desired.
178178
#[stable(feature = "rust1", since = "1.0.0")]
179179
#[lang = "copy"]
180180
pub trait Copy : Clone {

0 commit comments

Comments
 (0)