Skip to content

Commit 7ceb706

Browse files
authored
Rollup merge of #86200 - qwerty01:clone-doc-update, r=JohnTitor
Updates `Clone` docs for `Copy` comparison. Quite a few people (myself included) have come under the impression that the difference between `Copy` and `Clone` is that `Copy` is cheap and `Clone` is expensive, where the actual difference is that `Copy` constrains the type to bit-wise copying, and `Clone` allows for more expensive operations. The source of this misconception is in the `Clone` docs, where the following line is in the description: > Differs from `Copy` in that `Copy` is implicit and extremely inexpensive, while `Clone` is always explicit and may or may not be expensive. The `Clone` documentation page also comes up before the `Copy` page on google when searching for "the difference between `Clone` and `Copy`". This PR updates the documentation to clarify that "extremely inexpensive" means an "inexpensive bit-wise copy" to hopefully prevent future rust users from falling into this misunderstanding.
2 parents 163dbda + 2788c71 commit 7ceb706

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
/// A common trait for the ability to explicitly duplicate an object.
4040
///
41-
/// Differs from [`Copy`] in that [`Copy`] is implicit and extremely inexpensive, while
41+
/// Differs from [`Copy`] in that [`Copy`] is implicit and an inexpensive bit-wise copy, while
4242
/// `Clone` is always explicit and may or may not be expensive. In order to enforce
4343
/// these characteristics, Rust does not allow you to reimplement [`Copy`], but you
4444
/// may reimplement `Clone` and run arbitrary code.

0 commit comments

Comments
 (0)