Insert `block` in the layout *after* the existing block `after`.
(&mut self, block: Block, after: Block)
| 267 | |
| 268 | /// Insert `block` in the layout *after* the existing block `after`. |
| 269 | pub fn insert_block_after(&mut self, block: Block, after: Block) { |
| 270 | debug_assert!( |
| 271 | !self.is_block_inserted(block), |
| 272 | "Cannot insert block that is already in the layout" |
| 273 | ); |
| 274 | debug_assert!( |
| 275 | self.is_block_inserted(after), |
| 276 | "block Insertion point not in the layout" |
| 277 | ); |
| 278 | let before = self.blocks[after].next; |
| 279 | { |
| 280 | let node = &mut self.blocks[block]; |
| 281 | node.next = before; |
| 282 | node.prev = after.into(); |
| 283 | } |
| 284 | self.blocks[after].next = block.into(); |
| 285 | match before.expand() { |
| 286 | None => self.last_block = Some(block), |
| 287 | Some(b) => self.blocks[b].prev = block.into(), |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | /// Remove all instructions from `block` and then remove it from |
| 292 | /// the layout. |