2020-04-07 16:57:26 -05:00
|
|
|
error[E0373]: closure may outlive the current function, but it borrows `prefix`, which is owned by the current function
|
|
|
|
--> $DIR/does-not-live-long-enough.rs:6:33
|
2019-12-24 12:14:20 -06:00
|
|
|
|
|
|
|
|
LL | self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref())
|
2020-04-07 16:57:26 -05:00
|
|
|
| ^^^ ------ `prefix` is borrowed here
|
2019-12-24 12:14:20 -06:00
|
|
|
| |
|
2020-04-07 16:57:26 -05:00
|
|
|
| may outlive borrowed value `prefix`
|
|
|
|
|
|
|
|
|
note: closure is returned here
|
2022-02-14 10:10:22 -06:00
|
|
|
--> $DIR/does-not-live-long-enough.rs:6:9
|
2019-12-24 12:14:20 -06:00
|
|
|
|
|
2022-02-14 10:10:22 -06:00
|
|
|
LL | self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref())
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-04-07 16:57:26 -05:00
|
|
|
help: to force the closure to take ownership of `prefix` (and any other referenced variables), use the `move` keyword
|
2019-12-24 12:14:20 -06:00
|
|
|
|
|
2020-04-07 16:57:26 -05:00
|
|
|
LL | self.data.iter().filter(move |s| s.starts_with(prefix)).map(|s| s.as_ref())
|
2021-06-21 21:07:19 -05:00
|
|
|
| ++++
|
2019-12-24 12:14:20 -06:00
|
|
|
|
|
|
|
error: aborting due to previous error
|
|
|
|
|
2020-04-07 16:57:26 -05:00
|
|
|
For more information about this error, try `rustc --explain E0373`.
|