Skip to content

Commit 7568487

Browse files
committed
Add a nice big warning on get_arc about holding the Arc for long periods of time.
1 parent 3c7c24c commit 7568487

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/bevy_asset/src/assets.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,14 @@ impl<A: Asset> Assets<A> {
426426
}
427427

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

0 commit comments

Comments
 (0)