Skip to content

Commit

Permalink
Rollup merge of rust-lang#61652 - JohnTitor:docs-improve-array, r=Cen…
Browse files Browse the repository at this point in the history
…tril

Mention slice patterns in array

Fixes rust-lang#61650

r? @scottmcm
  • Loading branch information
Centril authored Jun 11, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents b4419a8 + 3cfceb9 commit 79ac254
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/libstd/primitive_docs.rs
Original file line number Diff line number Diff line change
@@ -482,8 +482,8 @@ mod prim_pointer { }
/// an array. Indeed, this provides most of the API for working with arrays.
/// Slices have a dynamic size and do not coerce to arrays.
///
/// There is no way to move elements out of an array. See [`mem::replace`][replace]
/// for an alternative.
/// You can move elements out of an array with a slice pattern. If you want
/// one element, see [`mem::replace`][replace].
///
/// # Examples
///
@@ -525,6 +525,16 @@ mod prim_pointer { }
/// for x in &array { }
/// ```
///
/// You can use a slice pattern to move elements out of an array:
///
/// ```
/// fn move_away(_: String) { /* Do interesting things. */ }
///
/// let [john, roa] = ["John".to_string(), "Roa".to_string()];
/// move_away(john);
/// move_away(roa);
/// ```
///
/// [slice]: primitive.slice.html
/// [copy]: marker/trait.Copy.html
/// [clone]: clone/trait.Clone.html

0 comments on commit 79ac254

Please sign in to comment.