gameServer2/src/server/room.rs
changeset 14371 31717e1436cd
parent 13810 0463a4221327
equal deleted inserted replaced
14370:d35e0fdb70f6 14371:31717e1436cd
   226         self.teams.iter_mut().find(|(_, t)| f(t)).map(|(id, t)| (*id, t))
   226         self.teams.iter_mut().find(|(_, t)| f(t)).map(|(id, t)| (*id, t))
   227     }
   227     }
   228 
   228 
   229     pub fn find_team<F>(&self, f: F) -> Option<&TeamInfo>
   229     pub fn find_team<F>(&self, f: F) -> Option<&TeamInfo>
   230         where F: Fn(&TeamInfo) -> bool {
   230         where F: Fn(&TeamInfo) -> bool {
   231         self.teams.iter().map(|(_, t)| t).find(|t| f(*t))
   231         self.teams.iter().find_map(|(_, t)| Some(t).filter(|t| f(&t)))
   232     }
   232     }
   233 
   233 
   234     pub fn client_teams(&self, client_id: ClientId) -> impl Iterator<Item = &TeamInfo> {
   234     pub fn client_teams(&self, client_id: ClientId) -> impl Iterator<Item = &TeamInfo> {
   235         client_teams_impl(&self.teams, client_id)
   235         client_teams_impl(&self.teams, client_id)
   236     }
   236     }