Advertisement
kalabukdima

Rust lifetime error

Aug 17th, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
  2. --> src/render.rs:45:34
  3. |
  4. 45 | self.texture_creator.create_texture_from_surface(
  5. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6. |
  7. note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 40:5...
  8. --> src/render.rs:40:5
  9. |
  10. 40 | / fn create_light_texture(&mut self) {
  11. 41 | | let light_radius = ((VISIBILITY_RADIUS as f32 - 1. / 2_f32.sqrt()) * CELL_SIZE as f32) as u32;
  12. 42 | | let texture_size = 1024;
  13. 43 | | let light_surface = create_light_surface(light_radius, texture_size).unwrap();
  14. ... |
  15. 49 | |
  16. 50 | | }
  17. | |_____^
  18. note: ...so that reference does not outlive borrowed content
  19. --> src/render.rs:45:13
  20. |
  21. 45 | self.texture_creator.create_texture_from_surface(
  22. | ^^^^^^^^^^^^^^^^^^^^
  23. note: but, the lifetime must be valid for the lifetime 'c as defined on the impl at 31:6...
  24. --> src/render.rs:31:6
  25. |
  26. 31 | impl<'c> Renderer<'c> {
  27. | ^^
  28. = note: ...so that the expression is assignable:
  29. expected std::option::Option<sdl2::render::Texture<'c>>
  30. found std::option::Option<sdl2::render::Texture<'_>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement