maplike/
thunderdome.rs

1// SPDX-FileCopyrightText: 2025 maplike contributors
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5use thunderdome::{Arena, Index};
6
7use crate::{Get, Insert, IntoIter, Keyed, Map, Push, Remove};
8
9impl<V> Map for Arena<V> {
10    type Item = V;
11}
12
13impl<V> Keyed for Arena<V> {
14    type Key = Index;
15}
16
17impl<V> Get<Index> for Arena<V> {
18    #[inline(always)]
19    fn get(&self, key: &Index) -> Option<&V> {
20        Arena::get(self, *key)
21    }
22}
23
24impl<V> Insert<Index> for Arena<V> {
25    #[inline(always)]
26    fn insert(&mut self, key: Index, value: V) {
27        Arena::insert_at(self, key, value);
28    }
29}
30
31impl<V> Remove<Index> for Arena<V> {
32    #[inline(always)]
33    fn remove(&mut self, key: &Index) -> Option<V> {
34        Arena::remove(self, *key)
35    }
36}
37
38impl<V> Push<Index> for Arena<V> {
39    #[inline(always)]
40    fn push(&mut self, value: V) -> Index {
41        Arena::insert(self, value)
42    }
43}
44
45impl<V> IntoIter<Index> for Arena<V> {
46    type IntoIter = thunderdome::iter::IntoIter<V>;
47
48    #[inline(always)]
49    fn into_iter(self) -> thunderdome::iter::IntoIter<V> {
50        IntoIterator::into_iter(self)
51    }
52}