Skip to content

Commit 3cfceb9

Browse files
committed
Add an example
1 parent 1a32a68 commit 3cfceb9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/primitive_docs.rs

+10
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,16 @@ mod prim_pointer { }
525525
/// for x in &array { }
526526
/// ```
527527
///
528+
/// You can use a slice pattern to move elements out of an array:
529+
///
530+
/// ```
531+
/// fn move_away(_: String) { /* Do interesting things. */ }
532+
///
533+
/// let [john, roa] = ["John".to_string(), "Roa".to_string()];
534+
/// move_away(john);
535+
/// move_away(roa);
536+
/// ```
537+
///
528538
/// [slice]: primitive.slice.html
529539
/// [copy]: marker/trait.Copy.html
530540
/// [clone]: clone/trait.Clone.html

0 commit comments

Comments
 (0)