cl-structures: Add get_many_mut
implementation for Pool (currently delegates to unstable std)
This commit is contained in:
parent
9c3c2e8674
commit
ef190f2d66
@ -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()
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user