]> git.lizzy.rs Git - rust.git/blob - src/docs/expl_impl_clone_on_copy.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / expl_impl_clone_on_copy.txt
1 ### What it does
2 Checks for explicit `Clone` implementations for `Copy`
3 types.
4
5 ### Why is this bad?
6 To avoid surprising behavior, these traits should
7 agree and the behavior of `Copy` cannot be overridden. In almost all
8 situations a `Copy` type should have a `Clone` implementation that does
9 nothing more than copy the object, which is what `#[derive(Copy, Clone)]`
10 gets you.
11
12 ### Example
13 ```
14 #[derive(Copy)]
15 struct Foo;
16
17 impl Clone for Foo {
18     // ..
19 }
20 ```