Insert `block` in the layout before the existing block `before`.
(&mut self, block: Block, before: Block)
| 244 | |
| 245 | /// Insert `block` in the layout before the existing block `before`. |
| 246 | pub fn insert_block(&mut self, block: Block, before: Block) { |
| 247 | debug_assert!( |
| 248 | !self.is_block_inserted(block), |
| 249 | "Cannot insert block that is already in the layout" |
| 250 | ); |
| 251 | debug_assert!( |
| 252 | self.is_block_inserted(before), |
| 253 | "block Insertion point not in the layout" |
| 254 | ); |
| 255 | let after = self.blocks[before].prev; |
| 256 | { |
| 257 | let node = &mut self.blocks[block]; |
| 258 | node.next = before.into(); |
| 259 | node.prev = after; |
| 260 | } |
| 261 | self.blocks[before].prev = block.into(); |
| 262 | match after.expand() { |
| 263 | None => self.first_block = Some(block), |
| 264 | Some(a) => self.blocks[a].next = block.into(), |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | /// Insert `block` in the layout *after* the existing block `after`. |
| 269 | pub fn insert_block_after(&mut self, block: Block, after: Block) { |