cl-structures: Add get_many_mut implementation for Pool (currently delegates to unstable std)

This commit is contained in:
John 2024-04-21 22:32:47 -05:00
parent 9c3c2e8674
commit ef190f2d66
2 changed files with 9 additions and 1 deletions

View File

@ -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<T, ID: InternKey> Pool<T, ID> {
self.pool.get_mut(index.get())
}
pub fn get_many_mut<const N: usize>(
&mut self,
indices: [ID; N],
) -> Result<[&mut T; N], GetManyMutError<N>> {
self.pool.get_many_mut(indices.map(|id| id.get()))
}
pub fn iter(&self) -> impl Iterator<Item = &T> {
self.pool.iter()
}

View File

@ -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;