Clean up E0515 explanation
This commit is contained in:
parent
167510f776
commit
e2e41c9527
@ -1,7 +1,4 @@
|
||||
Cannot return value that references local variable
|
||||
|
||||
Local variables, function parameters and temporaries are all dropped before the
|
||||
end of the function body. So a reference to them cannot be returned.
|
||||
A reference to a local variable was returned.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
@ -20,6 +17,9 @@ fn get_dangling_iterator<'a>() -> Iter<'a, i32> {
|
||||
}
|
||||
```
|
||||
|
||||
Local variables, function parameters and temporaries are all dropped before the
|
||||
end of the function body. So a reference to them cannot be returned.
|
||||
|
||||
Consider returning an owned value instead:
|
||||
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user