So I'm trying to squeeze in callbacks to this enum variant (Visual
) - which will be stored in a vector as seen within the struct EntityComponents
:
enum Component {
Position([f64; 2]),
Visual(& Fn(Entity) -> ()),
}
struct EntityComponents {
components_of_entity: HashMap<TypeId, Vec<Component>>,
}
However, Rust requires me to provide explicit lifetime parameters here.
My idea is that I want the function reference to live at least as long as its argument (the Entity
), but I have no idea how the syntax for that would look like? Is it even possible?
The idea is that as long as an Entity
has a Visual
component, we can use this callback to render it!