diff --git a/compiler/cl-structures/src/intern_pool.rs b/compiler/cl-structures/src/intern_pool.rs index deffced..654ab94 100644 --- a/compiler/cl-structures/src/intern_pool.rs +++ b/compiler/cl-structures/src/intern_pool.rs @@ -53,6 +53,7 @@ macro_rules! make_intern_key {($($(#[$meta:meta])* $name:ident),*$(,)?) => {$( } } )*}} +use core::slice::GetManyMutError; use std::ops::{Index, IndexMut}; pub use make_intern_key; @@ -91,6 +92,13 @@ impl Pool { self.pool.get_mut(index.get()) } + pub fn get_many_mut( + &mut self, + indices: [ID; N], + ) -> Result<[&mut T; N], GetManyMutError> { + self.pool.get_many_mut(indices.map(|id| id.get())) + } + pub fn iter(&self) -> impl Iterator { self.pool.iter() } diff --git a/compiler/cl-structures/src/lib.rs b/compiler/cl-structures/src/lib.rs index a986cf1..b0728a4 100644 --- a/compiler/cl-structures/src/lib.rs +++ b/compiler/cl-structures/src/lib.rs @@ -2,7 +2,7 @@ //! - [Span](struct@span::Span): Stores a start and end [Loc](struct@span::Loc) //! - [Loc](struct@span::Loc): Stores the index in a stream #![warn(clippy::all)] -#![feature(inline_const, dropck_eyepatch, decl_macro)] +#![feature(inline_const, dropck_eyepatch, decl_macro, get_many_mut)] #![deny(unsafe_op_in_unsafe_fn)] pub mod span;