(&mut self, id: Id)
| 429 | /// deallocate an arbitrary value. |
| 430 | #[inline] |
| 431 | pub fn dealloc(&mut self, id: Id) -> T { |
| 432 | let entry = core::mem::replace( |
| 433 | self.entries |
| 434 | .get_mut(id.0.index()) |
| 435 | .expect("id from a different slab"), |
| 436 | Entry::Free { next_free: None }, |
| 437 | ); |
| 438 | match entry { |
| 439 | Entry::Free { .. } => panic!("attempt to deallocate an entry that is already vacant"), |
| 440 | Entry::Occupied(value) => { |
| 441 | let next_free = core::mem::replace(&mut self.free, Some(id.0)); |
| 442 | self.entries[id.0.index()] = Entry::Free { next_free }; |
| 443 | self.len -= 1; |
| 444 | value |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | /// Iterate over all values currently allocated within this `Slab`. |
| 450 | /// |
no test coverage detected