Skip to content

issue with references and lifetimes #20072

Answered by RobWalt
sunnyzanchi asked this question in Q&A
Discussion options

You must be logged in to vote

This likely comes from the fact that you are using one lifetime for everything. For example in

asset_server: &'a Res<'a, AssetServer>,

you have 'a for both the lifetime of the reference to the resource and in the resource itself. But the two lifetimes describe different things:

  • lifetime to reference to the resource: how long do you borrow the resource yo your function
  • lifetime in the resource: how long borrows the resource something from the world in the ecs

You can most likely fix this by introducing more distinct lifetime parameters like 'b additionally to 'a

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sunnyzanchi
Comment options

Answer selected by sunnyzanchi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants