Turns out, collect is the answer
This commit is contained in:
		
							parent
							
								
									8f3c83311f
								
							
						
					
					
						commit
						10fb09eca2
					
				
					 1 changed files with 8 additions and 15 deletions
				
			
		|  | @ -42,21 +42,14 @@ impl<A> EntityMap<A> { | ||||||
| 
 | 
 | ||||||
|     /// Returns a list of all entities at the given position
 |     /// Returns a list of all entities at the given position
 | ||||||
|     pub fn at<'a>(&'a self, pos: Position) -> Vec<&'a A> { |     pub fn at<'a>(&'a self, pos: Position) -> Vec<&'a A> { | ||||||
|         // self.by_position.get(&pos).iter().flat_map(|eids| {
 |         self.by_position | ||||||
|         //     eids.iter()
 |             .get(&pos) | ||||||
|         //         .map(|eid| self.by_id.get(eid).expect(BY_POS_INVARIANT))
 |             .iter() | ||||||
|         // })
 |             .flat_map(|eids| { | ||||||
|         // gross.
 |                 eids.iter() | ||||||
|         match self.by_position.get(&pos) { |                     .map(|eid| self.by_id.get(eid).expect(BY_POS_INVARIANT)) | ||||||
|             None => Vec::new(), |             }) | ||||||
|             Some(eids) => { |             .collect() | ||||||
|                 let mut res = Vec::new(); |  | ||||||
|                 for eid in eids { |  | ||||||
|                     res.push(self.by_id.get(eid).expect(BY_POS_INVARIANT)); |  | ||||||
|                 } |  | ||||||
|                 res |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// Remove all entities at the given position
 |     /// Remove all entities at the given position
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue