(mut self)
| 266 | } |
| 267 | |
| 268 | pub fn to_resolved(mut self) -> ResolvedGroup { |
| 269 | if let Some(index) = self.index { |
| 270 | ResolvedGroup::Single(index) |
| 271 | } else if self.is_union { |
| 272 | if self.children.len() == 1 { |
| 273 | self.children.remove(0).to_resolved() |
| 274 | } else { |
| 275 | // Collapse union of unions |
| 276 | ResolvedGroup::Union( |
| 277 | self.offset, |
| 278 | self.children |
| 279 | .into_iter() |
| 280 | .flat_map(|child| match child.to_resolved() { |
| 281 | ResolvedGroup::Union(offset, children) if offset == self.offset => { |
| 282 | children |
| 283 | } |
| 284 | s => vec![s], |
| 285 | }) |
| 286 | .collect(), |
| 287 | ) |
| 288 | } |
| 289 | } else { |
| 290 | if self.children.len() == 1 { |
| 291 | self.children.remove(0).to_resolved() |
| 292 | } else { |
| 293 | ResolvedGroup::Struct( |
| 294 | self.offset, |
| 295 | self.children |
| 296 | .into_iter() |
| 297 | .map(|child| child.to_resolved()) |
| 298 | .collect(), |
| 299 | ) |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | pub fn group_structure( |
no test coverage detected