Skip to content

Commit 157f7c1

Browse files
committed
Add Derive not possible question to Copy
This adds a question and answer to the Q&A section of the Copy docs. Specifically, it asks the question I asked while reading the docs, and gives its answer.
1 parent 9316ae5 commit 157f7c1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/libcore/marker.rs

+6
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ pub trait Unsize<T: ?Sized> {
144144
/// Generalizing the latter case, any type implementing `Drop` can't be `Copy`, because it's
145145
/// managing some resource besides its own `size_of::<T>()` bytes.
146146
///
147+
/// ## What if I derive `Copy` on a type that can't?
148+
///
149+
/// If you try to derive `Copy` on a struct or enum, you will get a compile-time error.
150+
/// Specifically, with structs you'll get [E0204](https://doc.rust-lang.org/error-index.html#E0204)
151+
/// and with enums you'll get [E0205](https://doc.rust-lang.org/error-index.html#E0205).
152+
///
147153
/// ## When should my type be `Copy`?
148154
///
149155
/// Generally speaking, if your type _can_ implement `Copy`, it should. There's one important thing

0 commit comments

Comments
 (0)