(&mut self)
| 342 | |
| 343 | #[inline] |
| 344 | fn try_alloc_index(&mut self) -> Option<EntryIndex> { |
| 345 | self.free.take().or_else(|| { |
| 346 | if self.entries.len() < self.entries.capacity() { |
| 347 | let index = EntryIndex::new(self.entries.len()); |
| 348 | self.entries |
| 349 | .push(Entry::Free { next_free: None }) |
| 350 | .expect("have capacity"); |
| 351 | Some(index) |
| 352 | } else { |
| 353 | None |
| 354 | } |
| 355 | }) |
| 356 | } |
| 357 | |
| 358 | /// Allocate a `T` value within this slab, allocating additional underlying |
| 359 | /// storage if there is no available capacity. |