(&mut self, idx: Index)
| 297 | } |
| 298 | |
| 299 | fn dec(&mut self, idx: Index) { |
| 300 | let slot = &mut self.slots[idx]; |
| 301 | match slot { |
| 302 | Slot::Occupied { ref_count, .. } => { |
| 303 | if *ref_count == 0 { |
| 304 | *slot = Slot::Vacant { |
| 305 | next_free: self.next_free, |
| 306 | }; |
| 307 | self.next_free = idx; |
| 308 | } else { |
| 309 | *ref_count -= 1; |
| 310 | } |
| 311 | } |
| 312 | Slot::Vacant { .. } => panic!("taken slot has been improperly freed"), |
| 313 | } |
| 314 | } |
| 315 | } |