]> git.lizzy.rs Git - rust.git/commitdiff
Add Derive not possible question to Copy
authorRyan Scheel (Havvy) <ryan.havvy@gmail.com>
Tue, 26 Jul 2016 05:14:37 +0000 (05:14 +0000)
committerRyan Scheel (Havvy) <ryan.havvy@gmail.com>
Mon, 1 Aug 2016 05:43:13 +0000 (05:43 +0000)
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.

src/libcore/marker.rs

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