You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some of the examples in this section did not really prove the claim
they were making; let's adjust them to do this. Let's also simplify
and minimize them to match the style of other recent examples we're
adding and that of the ones that will follow in the section below.
One particular stylistic conundrum is what to do about comments like
this:
// ERROR: Borrow of moved value.
Normally, our stylistic convention would be to capitalize after the
comma in this case and end with a period. That's what we'd do, e.g.,
in a similar case like this:
// OK: The value can be moved here.
But, of course, `rustc` doesn't capitalize and add a period to these
kind of error messages, making it tempting to follow that lead.
Since we already don't always use the same error messages that `rustc`
does -- it's not a goal to match those -- it seems better to be
internally consistent with our own documentation norms. Let's
capitalize and add the period. We'll later add this to the style
guide and work to align the document with this.
Partial captures of arrays and slices are not supported; the entire slice or array is always captured even if used with wildcard pattern matching, indexing, or sub-slicing.
266
266
267
267
```rust,compile_fail,E0382
268
-
#[derive(Debug)]
269
-
struct Example;
270
-
let x = [Example, Example];
271
-
268
+
struct S; // A non-`Copy` type.
269
+
let mut x = [S, S];
272
270
let c = || {
273
-
let [first, _] = x; // captures all of `x` ByValue
271
+
let [x0, _] = x; // Captures all of `x` by `ByValue`.
274
272
};
275
-
c();
276
-
println!("{:?}", x[1]); // ERROR: borrow of moved value: `x`
273
+
let _ = &mut x[1]; // ERROR: Borrow of moved value.
0 commit comments