Remove `block` from the layout.
(&mut self, block: Block)
| 299 | |
| 300 | /// Remove `block` from the layout. |
| 301 | pub fn remove_block(&mut self, block: Block) { |
| 302 | debug_assert!(self.is_block_inserted(block), "block not in the layout"); |
| 303 | debug_assert!(self.first_inst(block).is_none(), "block must be empty."); |
| 304 | |
| 305 | // Clear the `block` node and extract links. |
| 306 | let prev; |
| 307 | let next; |
| 308 | { |
| 309 | let n = &mut self.blocks[block]; |
| 310 | prev = n.prev; |
| 311 | next = n.next; |
| 312 | n.prev = None.into(); |
| 313 | n.next = None.into(); |
| 314 | } |
| 315 | // Fix up links to `block`. |
| 316 | match prev.expand() { |
| 317 | None => self.first_block = next.expand(), |
| 318 | Some(p) => self.blocks[p].next = next, |
| 319 | } |
| 320 | match next.expand() { |
| 321 | None => self.last_block = prev.expand(), |
| 322 | Some(n) => self.blocks[n].prev = prev, |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | /// Return an iterator over all blocks in layout order. |
| 327 | pub fn blocks(&self) -> Blocks<'_> { |
no test coverage detected