amethyst/legion

Resources with a lifetime

tonyxty opened this issue · 1 comments

Currently Resources must be 'static, which makes it difficult to implement many functionalities as systems, notably rendering, since the textures / sprites / render contexts etc. usually have a lifetime associated with them.

My question is, is it possible to have resources that are generic over a lifetime parameter 'a and have Schedule::execute<'a>(&mut self, world: &mut World, resources: &'a mut Resource<'a>? After all, resources are not accessed outside of this function. Or is there some reason against this?

I guess it has to do with rust's requirements on the Any trait. For those who encountered the same problem: std::mem::transmute can be used to circumvent this, but is "the most horribly unsafe thing you can do in Rust" according to the nomicon. Use at your own risk.