File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -482,8 +482,8 @@ mod prim_pointer { }
482
482
/// an array. Indeed, this provides most of the API for working with arrays.
483
483
/// Slices have a dynamic size and do not coerce to arrays.
484
484
///
485
- /// There is no way to move elements out of an array. See [`mem::replace`][replace]
486
- /// for an alternative .
485
+ /// You can move elements out of an array with a slice pattern. If you want
486
+ /// one element, see [`mem::replace`][replace] .
487
487
///
488
488
/// # Examples
489
489
///
@@ -525,6 +525,16 @@ mod prim_pointer { }
525
525
/// for x in &array { }
526
526
/// ```
527
527
///
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
+ ///
528
538
/// [slice]: primitive.slice.html
529
539
/// [copy]: marker/trait.Copy.html
530
540
/// [clone]: clone/trait.Clone.html
You can’t perform that action at this time.
0 commit comments