Clean up E0373 explanation
This commit is contained in:
parent
01a8b5f26e
commit
129ac011b5
@ -1,6 +1,6 @@
|
||||
This error occurs when an attempt is made to use data captured by a closure,
|
||||
when that data may no longer exist. It's most commonly seen when attempting to
|
||||
return a closure:
|
||||
A captured variable in a closure may not live long enough.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0373
|
||||
fn foo() -> Box<Fn(u32) -> u32> {
|
||||
@ -9,6 +9,10 @@ fn foo() -> Box<Fn(u32) -> u32> {
|
||||
}
|
||||
```
|
||||
|
||||
This error occurs when an attempt is made to use data captured by a closure,
|
||||
when that data may no longer exist. It's most commonly seen when attempting to
|
||||
return a closure as shown in the previous code example.
|
||||
|
||||
Notice that `x` is stack-allocated by `foo()`. By default, Rust captures
|
||||
closed-over data by reference. This means that once `foo()` returns, `x` no
|
||||
longer exists. An attempt to access `x` within the closure would thus be
|
||||
|
Loading…
Reference in New Issue
Block a user