about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authormbartlett21 <29034492+mbartlett21@users.noreply.github.com>2021-06-22 22:24:46 +1000
committerGitHub <noreply@github.com>2021-06-22 22:24:46 +1000
commit9db5c483ab50d70db6381f70c17711e2e472c0d3 (patch)
tree6c8d23e13e3a48d358321af479abf709941c44a5 /compiler/rustc_error_codes/src
parent75ed34223adb02c7bbfa5ae5e62c48952ff29914 (diff)
downloadrust-9db5c483ab50d70db6381f70c17711e2e472c0d3.tar.gz
rust-9db5c483ab50d70db6381f70c17711e2e472c0d3.zip
Add destructuring example of E0508
This adds an example that destructures the array to move the value, instead of taking a reference or cloning.
Diffstat (limited to 'compiler/rustc_error_codes/src')
-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;
+}
+```