flip resource scope order (#1793)

I think [collection, thing_removed_from_collection] is a more natural order than [thing_removed_from_collection, collection]. Just a small tweak that I think we should include in 0.5.
This commit is contained in:
Carter Anderson 2021-04-01 02:24:42 +00:00
parent b657a9b39f
commit f520a341d5
5 changed files with 9 additions and 9 deletions

View file

@ -1110,7 +1110,7 @@ mod tests {
fn resource_scope() {
let mut world = World::default();
world.insert_resource::<i32>(0);
world.resource_scope(|mut value: Mut<i32>, world: &mut World| {
world.resource_scope(|world: &mut World, mut value: Mut<i32>| {
*value += 1;
assert!(!world.contains_resource::<i32>());
});

View file

@ -658,7 +658,7 @@ impl World {
/// world.insert_resource(A(1));
/// let entity = world.spawn().insert(B(1)).id();
///
/// world.resource_scope(|mut a: Mut<A>, world| {
/// world.resource_scope(|world, mut a: Mut<A>| {
/// let b = world.get_mut::<B>(entity).unwrap();
/// a.0 += b.0;
/// });
@ -666,7 +666,7 @@ impl World {
/// ```
pub fn resource_scope<T: Component, U>(
&mut self,
f: impl FnOnce(Mut<T>, &mut World) -> U,
f: impl FnOnce(&mut World, Mut<T>) -> U,
) -> U {
let component_id = self
.components
@ -692,7 +692,7 @@ impl World {
last_change_tick: self.last_change_tick(),
change_tick: self.change_tick(),
};
let result = f(value, self);
let result = f(self, value);
let resource_archetype = self.archetypes.resource_mut();
let unique_components = resource_archetype.unique_components_mut();
let column = unique_components

View file

@ -128,7 +128,7 @@ where
let query_state = self.query_state.get_or_insert_with(|| world.query());
let cameras = &self.cameras;
let commands = &mut self.commands;
world.resource_scope(|mut active_cameras: Mut<ActiveCameras>, world| {
world.resource_scope(|world, mut active_cameras: Mut<ActiveCameras>| {
let mut pipeline_camera_commands = HashMap::default();
let pipelines = world.get_resource::<Assets<PipelineDescriptor>>().unwrap();
let render_resource_context = &**world

View file

@ -115,7 +115,7 @@ impl SceneSpawner {
scene_handle: &Handle<DynamicScene>,
entity_map: &mut EntityMap,
) -> Result<(), SceneSpawnError> {
world.resource_scope(|scenes: Mut<Assets<DynamicScene>>, world| {
world.resource_scope(|world, scenes: Mut<Assets<DynamicScene>>| {
let scene =
scenes
.get(scene_handle)
@ -145,7 +145,7 @@ impl SceneSpawner {
};
let type_registry = world.get_resource::<TypeRegistryArc>().unwrap().clone();
let type_registry = type_registry.read();
world.resource_scope(|scenes: Mut<Assets<Scene>>, world| {
world.resource_scope(|world, scenes: Mut<Assets<Scene>>| {
let scene =
scenes
.get(&scene_handle)
@ -297,7 +297,7 @@ impl SceneSpawner {
}
pub fn scene_spawner_system(world: &mut World) {
world.resource_scope(|mut scene_spawner: Mut<SceneSpawner>, world| {
world.resource_scope(|world, mut scene_spawner: Mut<SceneSpawner>| {
let scene_asset_events = world
.get_resource::<Events<AssetEvent<DynamicScene>>>()
.unwrap();

View file

@ -101,7 +101,7 @@ impl WgpuRenderer {
}
pub fn run_graph(&mut self, world: &mut World) {
world.resource_scope(|mut render_graph: Mut<RenderGraph>, world| {
world.resource_scope(|world, mut render_graph: Mut<RenderGraph>| {
render_graph.prepare(world);
// stage nodes
let mut stager = DependentNodeStager::loose_grouping();