diff --git a/crates/bevy_ecs/hecs/src/entities.rs b/crates/bevy_ecs/hecs/src/entities.rs index 9b6aff3a88..6affb1c864 100644 --- a/crates/bevy_ecs/hecs/src/entities.rs +++ b/crates/bevy_ecs/hecs/src/entities.rs @@ -67,9 +67,7 @@ impl Entities { /// Access the location storage of an entity pub fn get_mut(&mut self, entity: Entity) -> Result<&mut Location, NoSuchEntity> { - self.entity_locations - .get_mut(&entity) - .ok_or_else(|| NoSuchEntity) + self.entity_locations.get_mut(&entity).ok_or(NoSuchEntity) } /// Access the location storage of an entity @@ -81,7 +79,7 @@ impl Entities { self.entity_locations .get(&entity) .cloned() - .ok_or_else(|| NoSuchEntity) + .ok_or(NoSuchEntity) } } diff --git a/crates/bevy_property/src/property_serde.rs b/crates/bevy_property/src/property_serde.rs index f66bf32bbe..e84b9b099b 100644 --- a/crates/bevy_property/src/property_serde.rs +++ b/crates/bevy_property/src/property_serde.rs @@ -111,9 +111,7 @@ impl<'a> MapSerializer<'a> { } fn format_type_name<'a>(registry: &'a PropertyTypeRegistry, type_name: &'a str) -> &'a str { - registry - .format_type_name(type_name) - .unwrap_or_else(|| type_name) + registry.format_type_name(type_name).unwrap_or(type_name) } impl<'a> Serialize for MapSerializer<'a> { diff --git a/crates/bevy_render/src/draw.rs b/crates/bevy_render/src/draw.rs index 42bfd7d961..7f01b5c2de 100644 --- a/crates/bevy_render/src/draw.rs +++ b/crates/bevy_render/src/draw.rs @@ -230,7 +230,7 @@ impl<'a> DrawContext<'a> { ) -> Result { self.shared_buffers .get_buffer(render_resource, buffer_usage) - .ok_or_else(|| DrawError::BufferAllocationFailure) + .ok_or(DrawError::BufferAllocationFailure) } pub fn set_pipeline( @@ -263,14 +263,14 @@ impl<'a> DrawContext<'a> { pub fn get_pipeline_descriptor(&self) -> Result<&PipelineDescriptor, DrawError> { self.current_pipeline .and_then(|handle| self.pipelines.get(&handle)) - .ok_or_else(|| DrawError::NoPipelineSet) + .ok_or(DrawError::NoPipelineSet) } pub fn get_pipeline_layout(&self) -> Result<&PipelineLayout, DrawError> { self.get_pipeline_descriptor().and_then(|descriptor| { descriptor .get_layout() - .ok_or_else(|| DrawError::PipelineHasNoLayout) + .ok_or(DrawError::PipelineHasNoLayout) }) } @@ -279,16 +279,14 @@ impl<'a> DrawContext<'a> { draw: &mut Draw, render_resource_bindings: &mut [&mut RenderResourceBindings], ) -> Result<(), DrawError> { - let pipeline = self - .current_pipeline - .ok_or_else(|| DrawError::NoPipelineSet)?; + let pipeline = self.current_pipeline.ok_or(DrawError::NoPipelineSet)?; let pipeline_descriptor = self .pipelines .get(&pipeline) - .ok_or_else(|| DrawError::NonExistentPipeline)?; + .ok_or(DrawError::NonExistentPipeline)?; let layout = pipeline_descriptor .get_layout() - .ok_or_else(|| DrawError::PipelineHasNoLayout)?; + .ok_or(DrawError::PipelineHasNoLayout)?; for bindings in render_resource_bindings.iter_mut() { bindings.update_bind_groups(pipeline_descriptor, &**self.render_resource_context); } @@ -311,16 +309,14 @@ impl<'a> DrawContext<'a> { index: u32, bind_group: &BindGroup, ) -> Result<(), DrawError> { - let pipeline = self - .current_pipeline - .ok_or_else(|| DrawError::NoPipelineSet)?; + let pipeline = self.current_pipeline.ok_or(DrawError::NoPipelineSet)?; let pipeline_descriptor = self .pipelines .get(&pipeline) - .ok_or_else(|| DrawError::NonExistentPipeline)?; + .ok_or(DrawError::NonExistentPipeline)?; let layout = pipeline_descriptor .get_layout() - .ok_or_else(|| DrawError::PipelineHasNoLayout)?; + .ok_or(DrawError::PipelineHasNoLayout)?; let bind_group_descriptor = &layout.bind_groups[index as usize]; self.render_resource_context .create_bind_group(bind_group_descriptor.id, bind_group); @@ -333,16 +329,14 @@ impl<'a> DrawContext<'a> { render_resource_bindings: &[&RenderResourceBindings], ) -> Result>, DrawError> { let mut indices = None; - let pipeline = self - .current_pipeline - .ok_or_else(|| DrawError::NoPipelineSet)?; + let pipeline = self.current_pipeline.ok_or(DrawError::NoPipelineSet)?; let pipeline_descriptor = self .pipelines .get(&pipeline) - .ok_or_else(|| DrawError::NonExistentPipeline)?; + .ok_or(DrawError::NonExistentPipeline)?; let layout = pipeline_descriptor .get_layout() - .ok_or_else(|| DrawError::PipelineHasNoLayout)?; + .ok_or(DrawError::PipelineHasNoLayout)?; for (slot, vertex_buffer_descriptor) in layout.vertex_buffer_descriptors.iter().enumerate() { for bindings in render_resource_bindings.iter() { diff --git a/crates/bevy_render/src/render_graph/node.rs b/crates/bevy_render/src/render_graph/node.rs index b7abe4eb91..35ca297540 100644 --- a/crates/bevy_render/src/render_graph/node.rs +++ b/crates/bevy_render/src/render_graph/node.rs @@ -144,7 +144,7 @@ impl NodeState { { self.node .downcast_ref::() - .ok_or_else(|| RenderGraphError::WrongNodeType) + .ok_or(RenderGraphError::WrongNodeType) } pub fn node_mut(&mut self) -> Result<&mut T, RenderGraphError> @@ -153,7 +153,7 @@ impl NodeState { { self.node .downcast_mut::() - .ok_or_else(|| RenderGraphError::WrongNodeType) + .ok_or(RenderGraphError::WrongNodeType) } pub fn validate_output_slots(&self) -> Result<(), RenderGraphError> { diff --git a/crates/bevy_sprite/src/texture_atlas_builder.rs b/crates/bevy_sprite/src/texture_atlas_builder.rs index 1a4459ae68..e508c447f7 100644 --- a/crates/bevy_sprite/src/texture_atlas_builder.rs +++ b/crates/bevy_sprite/src/texture_atlas_builder.rs @@ -110,7 +110,7 @@ impl TextureAtlasBuilder { } } - let rect_placements = rect_placements.ok_or_else(|| RectanglePackError::NotEnoughSpace)?; + let rect_placements = rect_placements.ok_or(RectanglePackError::NotEnoughSpace)?; let mut texture_rects = Vec::with_capacity(rect_placements.packed_locations().len()); let mut texture_handles = HashMap::default();