diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index 5f4a053846599..6f30e3428fa99 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -215,6 +215,19 @@ impl DenseAssetStorage { } } + pub(crate) fn get_many(&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> { let entry = self.storage.get_mut(index.index as usize)?; match entry { @@ -229,6 +242,13 @@ impl DenseAssetStorage { } } + pub(crate) fn get_many_mut( + &mut self, + indices: [AssetIndex; N], + ) -> [Option<&mut A>; N] { + todo!() + } + pub(crate) fn flush(&mut self) { // NOTE: this assumes the allocator index is monotonically increasing. let new_len = self