bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Change relevant methods in World and co to return ResMut

Open lynn-lumen opened this issue 1 year ago • 0 comments

Objective

  • Fixes #11765

Solution

  • Changed the current implementations to use ResMut instead of Mut

Changelog

  • In World: resource_mut, get_resource_mut, get_resource_or_insert_with now return ResMut / Option<ResMut> and resource_scopenow accepts a function parameter of type impl FnOnce(&mut World, ResMut<R>) -> U
  • In UnsafeWorldCell: get_resource_mut now returns Option<ResMut>
  • Changed internal uses of these methods to use ResMut aswell.
  • ResMut<R> now implements From<Mut<R: Resource>>

Migration Guide

  • For most use cases this should not require any action besides changing Mut<T> to ResMut<T> since they are very similar to each other and Mut<T> implements From<ResMut<'w, T>> for Mut<'w, T>. But you could just call .into() if any problems arise.

lynn-lumen avatar Feb 08 '24 02:02 lynn-lumen