add_to_entity_registry

Function add_to_entity_registry 

Source
pub fn add_to_entity_registry<R: Entity>()
Expand description

Adds a new entity to the registry. The job of this method is to create whatever “singleton” data/metadata is associated with the Entity if it doesn’t already exist, which in this case is only the value of Entity::id().

In our use case, this method is called in the ctor function of each Entity type and ultimately exists only so that we know how many EntityRecords to construct in the constructor of EntityStore, so that we never have to mutate EntityStore itself when an Entity is accessed for the first time. (The OnceCells handle the interior mutability required for initialization.)