The single unit with this ID. Use this method to get detailed statistics on a unit: heat, cooldowns, and properties of special abilities like units garrisoned in a rocket. NoSuchUnit - the unit does not exist (inside the vision range).
(&self, id: UnitID)
| 473 | /// |
| 474 | /// * NoSuchUnit - the unit does not exist (inside the vision range). |
| 475 | pub fn unit(&self, id: UnitID) -> Result<Unit, GameError> { |
| 476 | if let Some(unit) = self.my_planet().units.get(&id) { |
| 477 | Ok(unit.clone()) |
| 478 | } else if let Some(unit) = self.my_team().units_in_space.get(&id) { |
| 479 | Ok(unit.clone()) |
| 480 | } else { |
| 481 | Err(GameError::NoSuchUnit)? |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | /// All the units within the vision range, in no particular order. |
| 486 | /// Does not include units in space. |
no test coverage detected