Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- impl<'r> Ecs<'r> {
- pub fn add_entity<A: 'static>(&'r mut self) {
- let index: usize = {
- let p: Option<usize> = {
- self.world // immutable borrow here
- .iter()
- .position(|store| {
- store.types().len() == 1 && store.types().all(|ty| *ty == TypeId::of::<A>())
- })
- };
- let index = p.unwrap_or(self.world.len());
- if p.is_none() {
- let mut store = VecTypeStore::new();
- store.insert(Vec::<A>::new());
- self.world.push(store); // mutable borrow here
- }
- index
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement