Trouble Implementing ECS

Well, i'm trying to accomplish an ECS, Entity Component System.
I "invented" this system where each component changes the entire world including itself.

Entity Fox tries to kill Entity Bunny if finds it

Rust pseudo code:

trait Components {
    fn call_every_turn(api) {}
impl Components for Hostile {
    fn call_every_turn(api) {
// if hostile finds bunny, kills it.
           if let some((index_bunny, _))) = api.get_entity::<bunny>() {

trait Entity {
    fn new(api) {}
// so Hostile is inside Fox.
impl Entity for Fox {
   fn new(api){
struct Api {
    entities_vec = Vec<(Entity, Vec<dyn Components) 
    // Entities and Components
impl Api {
    fn get_entity<Entity: 'static>(&self, ent_id) -> (ent_id, Entity) {
         for (id, entity) in self.entities[ent_id].0. enumerate() {
            if let some(entity) (entity.dowcast to comp) 
                   return (id, entity)
    fn remove_ent(id)  { self.entities.remove(i) } // "Kills" it
    fn add_components(comp) ...
    fn call_every_turn(&mut self) {
          for ent in self.entities { // iterate entities
                for comp in ent.1 { // iterate components
                     comp.call_every_turn(self);  // problem
                     // can't borrow mutable twice 

So there is no way to make this system work?

Double posting the same thing won't lead you to getting better answers.

Is a different question.

Correct me if I am wrong, but this comment on your previous question is exactly the same as the question in this post, including the beginning "well...".
If you wanted feedback on this code, that comment is enough, you don't need to post again.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.