Advertisement
Guest User

TryFilter Errors

a guest
Jul 21st, 2023
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. error: lifetime may not live long enough
  2. --> src\funcs\mod.rs:59:49
  3. |
  4. 59 | .try_filter(async move |device| {
  5. | _________________________________________-------_^
  6. | | | |
  7. | | | return type of closure `[async closure body@src\funcs\mod.rs:59:49: 62:18]` contains a lifetime `'2`
  8. | | has type `&'1 brightness::BrightnessDevice`
  9. 60 | | let devname: Result<String, brightness::Error> = device.device_name().await;
  10. 61 | | devname.is_ok_and(|devname| device_names.contains(&devname)) // bool
  11. 62 | | })
  12. | |_________________^ returning this value requires that `'1` must outlive `'2`
  13.  
  14. error[E0507]: cannot move out of `device_names`, a captured variable in an `FnMut` closure
  15. --> src\funcs\mod.rs:59:49
  16. |
  17. 53 | device_names: Arc<HashSet<String>>,
  18. | ------------ captured outer variable
  19. ...
  20. 59 | .try_filter(async move |device| {
  21. | _____________________________-------------------_^
  22. | | |
  23. | | captured by this `FnMut` closure
  24. 60 | | let devname: Result<String, brightness::Error> = device.device_name().await;
  25. 61 | | devname.is_ok_and(|devname| device_names.contains(&devname)) // bool
  26. | | ------------
  27. | | |
  28. | | variable moved due to use in generator
  29. | | move occurs because `device_names` has type `Arc<HashSet<std::string::String>>`, which does not implement the `Copy` trait
  30. 62 | | })
  31. | |_________________^ `device_names` is moved here
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement