Skip to content

Commit

Permalink
resolve errors from latest clippy version
Browse files Browse the repository at this point in the history
  • Loading branch information
cart authored and mrk-its committed Oct 6, 2020
1 parent a0b9cf0 commit ecc76f2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 28 deletions.
6 changes: 2 additions & 4 deletions crates/bevy_ecs/hecs/src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -81,7 +79,7 @@ impl Entities {
self.entity_locations
.get(&entity)
.cloned()
.ok_or_else(|| NoSuchEntity)
.ok_or(NoSuchEntity)
}
}

Expand Down
4 changes: 1 addition & 3 deletions crates/bevy_property/src/property_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
30 changes: 12 additions & 18 deletions crates/bevy_render/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl<'a> DrawContext<'a> {
) -> Result<RenderResourceBinding, DrawError> {
self.shared_buffers
.get_buffer(render_resource, buffer_usage)
.ok_or_else(|| DrawError::BufferAllocationFailure)
.ok_or(DrawError::BufferAllocationFailure)
}

pub fn set_pipeline(
Expand Down Expand Up @@ -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)
})
}

Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -333,16 +329,14 @@ impl<'a> DrawContext<'a> {
render_resource_bindings: &[&RenderResourceBindings],
) -> Result<Option<Range<u32>>, 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() {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_render/src/render_graph/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl NodeState {
{
self.node
.downcast_ref::<T>()
.ok_or_else(|| RenderGraphError::WrongNodeType)
.ok_or(RenderGraphError::WrongNodeType)
}

pub fn node_mut<T>(&mut self) -> Result<&mut T, RenderGraphError>
Expand All @@ -153,7 +153,7 @@ impl NodeState {
{
self.node
.downcast_mut::<T>()
.ok_or_else(|| RenderGraphError::WrongNodeType)
.ok_or(RenderGraphError::WrongNodeType)
}

pub fn validate_output_slots(&self) -> Result<(), RenderGraphError> {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/texture_atlas_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ecc76f2

Please sign in to comment.