diff --git a/src/agent.rs b/src/agent.rs index 7c339ed..260a922 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -26,12 +26,12 @@ impl From<(Distance, Distance)> for Direction { pub type AgentId = usize; -pub struct WorldView { +pub struct WorldView<'o> { pub self_id: AgentId, pub tagged: AgentId, pub tagged_by: Option, pub bounds_distance: (Distance, Distance, Distance, Distance), - pub other_agents: Vec<(Direction, AgentId)>, + pub other_agents: &'o mut dyn Iterator, } #[derive(Debug)] diff --git a/src/world.rs b/src/world.rs index 4fe9ada..581d006 100644 --- a/src/world.rs +++ b/src/world.rs @@ -58,7 +58,7 @@ impl ActualWorld { tagged_by: self.state.tagged_by, tagged: self.state.tagged, bounds_distance: (pos.y, self.size.x - pos.x, self.size.y - pos.y, pos.x), - other_agents: self + other_agents: &mut self .state .agent_positions .iter() @@ -71,8 +71,7 @@ impl ActualWorld { }, *id, ) - }) - .collect(), + }), }), ) })