Summary

With specialization on the way, we need to talk about the semantics of <T as Clone>::clone() where T: Copy.

It's generally been an unspoken rule of Rust that a clone of a Copy type is equivalent

等価
to a memcpy of that type; however, that fact is not documented
文書
anywhere.
どこでも
This fact should be in the documentation
文書
for the Clone trait, just like the fact that T: Eq should implement
実装する
a == b == c == a rules.

Motivation

Currently, Vec::clone() is implemented

実装する
by creating a new Vec, and then cloning all of the elements
要素
from one into the other. This is slow in debug mode, and may not always be optimized (although it often will be). Specialization would allow
許可する、可能にする
us to simply memcpy the values from the old Vec to the new Vec in the case of T: Copy. However, if we don't specify
特定する、指定する、規定する
this, we will not be able to, and we will be stuck looping over every value.

It's always been the intention that Clone::clone == ptr::read for T: Copy; see issue #23790: "It really makes sense for Clone to be a supertrait of Copy -- Copy is a refinement of Clone where memcpy suffices, basically." This idea was also implicit

暗黙の
in accepting
受け付ける、受理する
rfc #0839 where "[B]ecause Copy: Clone, it would be backwards compatible to upgrade to Clone in the future if demand is high enough."

Detailed design
設計(する)

Specify

特定する、指定する、規定する
that <T as Clone>::clone(t) shall be equivalent
等価
to ptr::read(t) where T: Copy, t: &T. An implementation
実装
that does not uphold this shall not result
結果、戻り値
in undefined behavior;
ふるまい
Clone is not an unsafe trait.

Also add something like the following sentence to the documentation

文書
for the Clone trait:

"If T: Copy, x: T, and y: &T, then let x = y.clone(); is equivalent

等価
to let x = *y;. Manual
マニュアル、手動
implementations
実装
must be careful to uphold this."

Drawbacks

This is a breaking change, technically, although it breaks code that was malformed in the first place.

Alternatives

The alternative

代わりのもの、選択肢
is that, for each type and function we would like to specialize in this way, we document
文書
this separately. This is how we started off with clone_from_slice.

Unresolved questions

What the exact wording should be.