resolve errors from latest clippy version

This commit is contained in:
Carter Anderson 2020-09-07 15:00:03 -07:00
parent d86fae8147
commit 413caae7bb
5 changed files with 18 additions and 28 deletions

View file

@ -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)
}
}

View file

@ -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> {

View file

@ -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(
@ -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<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() {

View file

@ -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>
@ -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> {

View file

@ -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();