提交 7f72b311 编写于 作者: K kennytm 提交者: GitHub

Rollup merge of #45339 - xfix:patch-4, r=steveklabnik

Update array documentation for Clone trait changes

Just a note, for this to work, `T` doesn't have to `Copy`, `Clone` is sufficient. For instance, the following works.

```rust
fn x(a: &[String; 100]) -> [String; 100] {
    a.clone()
}
```
...@@ -284,7 +284,6 @@ mod prim_pointer { } ...@@ -284,7 +284,6 @@ mod prim_pointer { }
/// Arrays of sizes from 0 to 32 (inclusive) implement the following traits if /// Arrays of sizes from 0 to 32 (inclusive) implement the following traits if
/// the element type allows it: /// the element type allows it:
/// ///
/// - [`Clone`][clone] (only if `T: `[`Copy`][copy])
/// - [`Debug`][debug] /// - [`Debug`][debug]
/// - [`IntoIterator`][intoiterator] (implemented for `&[T; N]` and `&mut [T; N]`) /// - [`IntoIterator`][intoiterator] (implemented for `&[T; N]` and `&mut [T; N]`)
/// - [`PartialEq`][partialeq], [`PartialOrd`][partialord], [`Eq`][eq], [`Ord`][ord] /// - [`PartialEq`][partialeq], [`PartialOrd`][partialord], [`Eq`][eq], [`Ord`][ord]
...@@ -299,8 +298,10 @@ mod prim_pointer { } ...@@ -299,8 +298,10 @@ mod prim_pointer { }
/// entirely different types. As a stopgap, trait implementations are /// entirely different types. As a stopgap, trait implementations are
/// statically generated up to size 32. /// statically generated up to size 32.
/// ///
/// Arrays of *any* size are [`Copy`][copy] if the element type is [`Copy`][copy]. This /// Arrays of *any* size are [`Copy`][copy] if the element type is [`Copy`][copy]
/// works because the [`Copy`][copy] trait is specially known to the compiler. /// and [`Clone`][clone] if the element type is [`Clone`][clone]. This works
/// because [`Copy`][copy] and [`Clone`][clone] traits are specially known
/// to the compiler.
/// ///
/// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on /// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on
/// an array. Indeed, this provides most of the API for working with arrays. /// an array. Indeed, this provides most of the API for working with arrays.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册