Skip to content

Commit

Permalink
Add a nice big warning on get_arc about holding the Arc for long …
Browse files Browse the repository at this point in the history
…periods of time.
  • Loading branch information
andriyDev committed Oct 31, 2024
1 parent 3c7c24c commit 7568487
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/bevy_asset/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,14 @@ impl<A: Asset> Assets<A> {
}

/// Retrieves the [`Arc`] of an [`Asset`] with the given `id`, if it exists.
/// Note that this supports anything that implements `Into<AssetId<A>>`, which includes [`Handle`] and [`AssetId`].
///
/// Note that this supports anything that implements `Into<AssetId<A>>`, which includes
/// [`Handle`] and [`AssetId`]. Be careful with holding the Arc indefinitely: holding the
/// [`Arc`] (or a [`Weak`]) prevents the asset from being mutated in place. This can incur
/// clones when using `get_cloned_mut`, or can just entirely block mutation when using
/// `get_inplace_mut`.
///
/// [`Weak`]: std::sync::Weak
#[inline]
pub fn get_arc(&self, id: impl Into<AssetId<A>>) -> Option<Arc<A>> {
match id.into() {
Expand Down

0 comments on commit 7568487

Please sign in to comment.