wasmer_runtime_core_near/structures/mod.rs
1//! The structures module contains commonly used data structures.
2mod boxed;
3mod map;
4mod slice;
5
6pub use self::boxed::BoxedMap;
7pub use self::map::{Iter, IterMut, Map};
8pub use self::slice::SliceMap;
9
10/// A trait for dealing with type-safe indices into associative data structures
11/// like [`Map`]s.
12///
13/// Through the use of this trait, we get compile time checks that we are not
14/// using the wrong type of index into our data structures.
15///
16/// It acts as a thin wrapper over `usize` and in most usage patterns has no
17/// runtime overhead.
18pub trait TypedIndex: Copy + Clone {
19 /// Create a new instance of [`TypedIndex`] from a raw index value
20 #[doc(hidden)]
21 fn new(index: usize) -> Self;
22 /// Get the raw index value from the [`TypedIndex`]
23 #[doc(hidden)]
24 fn index(&self) -> usize;
25}