Support for get_many
and get_many_mut
functions for Assets<T>
Part of #16244
This commit is contained in:
parent
e155fe1d86
commit
b141be92e0
@ -215,6 +215,19 @@ impl<A: Asset> DenseAssetStorage<A> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_many<const N: usize>(&self, indices: [AssetIndex; N]) -> [Option<&A>; N] {
|
||||||
|
indices.map(|index| match self.storage.get(index.index as usize)? {
|
||||||
|
Entry::None => None,
|
||||||
|
Entry::Some { value, generation } => {
|
||||||
|
if *generation == index.generation {
|
||||||
|
value.as_ref()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn get_mut(&mut self, index: AssetIndex) -> Option<&mut A> {
|
pub(crate) fn get_mut(&mut self, index: AssetIndex) -> Option<&mut A> {
|
||||||
let entry = self.storage.get_mut(index.index as usize)?;
|
let entry = self.storage.get_mut(index.index as usize)?;
|
||||||
match entry {
|
match entry {
|
||||||
@ -229,6 +242,13 @@ impl<A: Asset> DenseAssetStorage<A> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_many_mut<const N: usize>(
|
||||||
|
&mut self,
|
||||||
|
indices: [AssetIndex; N],
|
||||||
|
) -> [Option<&mut A>; N] {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn flush(&mut self) {
|
pub(crate) fn flush(&mut self) {
|
||||||
// NOTE: this assumes the allocator index is monotonically increasing.
|
// NOTE: this assumes the allocator index is monotonically increasing.
|
||||||
let new_len = self
|
let new_len = self
|
||||||
|
Loading…
Reference in New Issue
Block a user