about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-06-23 00:20:23 +0200
committerGitHub <noreply@github.com>2021-06-23 00:20:23 +0200
commit68485b47976f8fdb4da11f202bd17d99c91cd2d3 (patch)
treec0f476ffb9f774d28ee71e7347164b14197c3bfc
parentf19aad85a8736d13af677e50188f08cf900a1d03 (diff)
parent9db5c483ab50d70db6381f70c17711e2e472c0d3 (diff)
downloadrust-68485b47976f8fdb4da11f202bd17d99c91cd2d3.tar.gz
rust-68485b47976f8fdb4da11f202bd17d99c91cd2d3.zip
Rollup merge of #86549 - mbartlett21:patch-1, r=GuillaumeGomez
Add destructuring example of E0508

This adds an example that destructures the array to move the value, instead of taking a reference or cloning.
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0508.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0508.md b/compiler/rustc_error_codes/src/error_codes/E0508.md
index 33572fca6a3..91865907bf2 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0508.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0508.md
@@ -39,3 +39,16 @@ fn main() {
     let _value = array[0].clone();
 }
 ```
+
+If you really want to move the value out, you can use a destructuring array
+pattern to move it:
+
+```
+struct NonCopy;
+
+fn main() {
+    let array = [NonCopy; 1];
+    // Destructuring the array
+    let [_value] = array;
+}
+```