solar_data_structures/index.rs
1//! Index types. See [`::oxc_index`].
2
3pub use oxc_index::{
4 Idx, IdxRangeBounds, IdxSliceIndex, IndexBox, IndexSlice, IndexVec, index_box, index_vec,
5 nonmax::NonMaxU32,
6};
7
8/// Creates a new index type backed by `NonMaxU32`, with niche optimization for `Option<T>`.
9#[macro_export]
10macro_rules! newtype_index {
11 ($($(#[$attr:meta])* $vis:vis struct $name:ident;)*) => {$(
12 $crate::index::define_nonmax_u32_index_type! {
13 $(#[$attr])*
14 $vis struct $name;
15 }
16
17 impl $name {
18 /// The maximum index value.
19 $vis const MAX: Self = Self::new(Self::MAX_INDEX);
20 }
21
22 impl $crate::bit_set::BitSetIndex for $name {
23 #[inline]
24 fn from_usize(index: usize) -> Self {
25 <Self as $crate::index::Idx>::from_usize(index)
26 }
27
28 #[inline]
29 fn index(self) -> usize {
30 <Self as $crate::index::Idx>::index(self)
31 }
32 }
33 )*};
34}
35
36pub use oxc_index::define_nonmax_u32_index_type;