Side Effects: * If @old_child.parent is set, replace @old_child with @new_child in @old_child's underlying Node structure. OR * Otherwise, this function does nothing.
(old_child: LN, new_child: LN)
| 491 | |
| 492 | |
| 493 | def replace_child(old_child: LN, new_child: LN) -> None: |
| 494 | """ |
| 495 | Side Effects: |
| 496 | * If @old_child.parent is set, replace @old_child with @new_child in |
| 497 | @old_child's underlying Node structure. |
| 498 | OR |
| 499 | * Otherwise, this function does nothing. |
| 500 | """ |
| 501 | parent = old_child.parent |
| 502 | if not parent: |
| 503 | return |
| 504 | |
| 505 | child_idx = old_child.remove() |
| 506 | if child_idx is not None: |
| 507 | parent.insert_child(child_idx, new_child) |
| 508 | |
| 509 | |
| 510 | def container_of(leaf: Leaf) -> LN: |
no test coverage detected