Add reserve_handle to Assets. (#10939)

# Objective

Fixes #10938.

## Solution

Adds `reserve_handle` to `Assets`.

---

## Changelog

- Added `reserve_handle` to `Assets`.
This commit is contained in:
andriyDev 2024-01-08 14:17:29 -08:00 committed by GitHub
parent a795de30b4
commit da485c29b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -299,6 +299,11 @@ impl<A: Asset> Assets<A> {
self.handle_provider.clone()
}
/// Reserves a new [`Handle`] for an asset that will be stored in this collection.
pub fn reserve_handle(&self) -> Handle<A> {
self.handle_provider.reserve_handle().typed::<A>()
}
/// Inserts the given `asset`, identified by the given `id`. If an asset already exists for `id`, it will be replaced.
pub fn insert(&mut self, id: impl Into<AssetId<A>>, asset: A) {
let id: AssetId<A> = id.into();