From a721f3595dbac63387ef8924c13d4d397dd6a4e0 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sun, 9 Feb 2020 11:43:45 -0800 Subject: [PATCH] rustfmt: use field init shorthand --- rustfmt.toml | 3 ++- src/asset/texture.rs | 2 +- src/render/passes/forward_instanced/mod.rs | 4 ++-- src/render/passes/ui/mod.rs | 4 ++-- .../render_graph_2/renderers/wgpu_renderer.rs | 19 +++++-------------- .../light_resource_provider.rs | 2 +- .../global_2d_resource_manager.rs | 2 +- .../global_resource_manager.rs | 2 +- .../light_resource_manager.rs | 2 +- src/render/vertex.rs | 8 ++++---- src/serialization/world.rs | 2 +- 11 files changed, 21 insertions(+), 29 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 2461f06545..718513f7ce 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1,2 @@ -merge_imports = true \ No newline at end of file +merge_imports = true +use_field_init_shorthand = true \ No newline at end of file diff --git a/src/asset/texture.rs b/src/asset/texture.rs index 909ca24f1b..977fa9278f 100644 --- a/src/asset/texture.rs +++ b/src/asset/texture.rs @@ -14,7 +14,7 @@ impl Asset for Texture { TextureType::Data(data) => data.clone(), }; - Texture { data: data } + Texture { data } } } diff --git a/src/render/passes/forward_instanced/mod.rs b/src/render/passes/forward_instanced/mod.rs index 0fc502a1d8..5a19cfc673 100644 --- a/src/render/passes/forward_instanced/mod.rs +++ b/src/render/passes/forward_instanced/mod.rs @@ -84,7 +84,7 @@ impl ForwardInstancedPipeline { } instance_buffer_infos.push(InstanceBufferInfo { - mesh_id: mesh_id, + mesh_id, buffer: temp_buf_data.finish(), instance_count: entity_count, }); @@ -126,7 +126,7 @@ impl ForwardInstancedPipeline { let mut instance_buffer_infos = Vec::new(); instance_buffer_infos.push(InstanceBufferInfo { mesh_id: last_mesh_id.unwrap(), - buffer: buffer, + buffer, instance_count: entities_count, }); diff --git a/src/render/passes/ui/mod.rs b/src/render/passes/ui/mod.rs index cd4d312642..c0f1d198ca 100644 --- a/src/render/passes/ui/mod.rs +++ b/src/render/passes/ui/mod.rs @@ -84,8 +84,8 @@ impl UiPipeline { let mut instance_buffer_infos = Vec::new(); instance_buffer_infos.push(InstanceBufferInfo { - mesh_id: mesh_id, - buffer: buffer, + mesh_id, + buffer, instance_count: data.len(), }); diff --git a/src/render/render_graph_2/renderers/wgpu_renderer.rs b/src/render/render_graph_2/renderers/wgpu_renderer.rs index e33451cc61..4d43b07576 100644 --- a/src/render/render_graph_2/renderers/wgpu_renderer.rs +++ b/src/render/render_graph_2/renderers/wgpu_renderer.rs @@ -272,7 +272,7 @@ impl WgpuRenderer { { let buffer = self.buffers.get(&b.name).unwrap(); wgpu::BindingResource::Buffer { - buffer: buffer, + buffer, range: 0..*size, } } else { @@ -370,16 +370,13 @@ impl WgpuRenderer { let buffer_usage = wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::UNIFORM; let buffer = self.device.create_buffer(&wgpu::BufferDescriptor { - size: size, + size, usage: buffer_usage, }); self.resource_info.insert( name.to_string(), - ResourceInfo::Buffer { - buffer_usage, - size: size, - }, + ResourceInfo::Buffer { buffer_usage, size }, ); self.buffers.insert(name.to_string(), buffer); @@ -553,17 +550,11 @@ impl Renderer for WgpuRenderer { fn create_buffer(&mut self, name: &str, size: u64, buffer_usage: wgpu::BufferUsage) { let buffer = self.device.create_buffer(&wgpu::BufferDescriptor { - size: size, + size, usage: buffer_usage, }); - self.add_resource_info( - name, - ResourceInfo::Buffer { - buffer_usage, - size: size, - }, - ); + self.add_resource_info(name, ResourceInfo::Buffer { buffer_usage, size }); self.buffers.insert(name.to_string(), buffer); } diff --git a/src/render/render_graph_2/resource_providers/light_resource_provider.rs b/src/render/render_graph_2/resource_providers/light_resource_provider.rs index ff69fa3315..b2e68b4cbc 100644 --- a/src/render/render_graph_2/resource_providers/light_resource_provider.rs +++ b/src/render/render_graph_2/resource_providers/light_resource_provider.rs @@ -21,7 +21,7 @@ impl LightResourceProvider { pub fn new(max_lights: usize) -> Self { LightResourceProvider { lights_are_dirty: true, - max_lights: max_lights, + max_lights, } } } diff --git a/src/render/render_resources/global_2d_resource_manager.rs b/src/render/render_resources/global_2d_resource_manager.rs index 913b82d68d..65f7ac8cb6 100644 --- a/src/render/render_resources/global_2d_resource_manager.rs +++ b/src/render/render_resources/global_2d_resource_manager.rs @@ -27,7 +27,7 @@ impl RenderResourceManager for Global2dResourceManager { ); let uniform_buffer = UniformBuffer { - buffer: buffer, + buffer, size: uniform_size, }; render_graph.set_uniform_buffer(GLOBAL_2D_UNIFORM_BUFFER_NAME, uniform_buffer); diff --git a/src/render/render_resources/global_resource_manager.rs b/src/render/render_resources/global_resource_manager.rs index 025b406465..a941d97220 100644 --- a/src/render/render_resources/global_resource_manager.rs +++ b/src/render/render_resources/global_resource_manager.rs @@ -27,7 +27,7 @@ impl RenderResourceManager for GlobalResourceManager { ); let uniform_buffer = UniformBuffer { - buffer: buffer, + buffer, size: uniform_size, }; render_graph.set_uniform_buffer(FORWARD_UNIFORM_BUFFER_NAME, uniform_buffer); diff --git a/src/render/render_resources/light_resource_manager.rs b/src/render/render_resources/light_resource_manager.rs index 07c516de9b..3f86632a7e 100644 --- a/src/render/render_resources/light_resource_manager.rs +++ b/src/render/render_resources/light_resource_manager.rs @@ -18,7 +18,7 @@ impl LightResourceManager { pub fn new(max_lights: usize) -> Self { LightResourceManager { lights_are_dirty: true, - max_lights: max_lights, + max_lights, } } } diff --git a/src/render/vertex.rs b/src/render/vertex.rs index 426b7c6f97..3d194478ad 100644 --- a/src/render/vertex.rs +++ b/src/render/vertex.rs @@ -40,9 +40,9 @@ impl Vertex { impl From<([f32; 4], [f32; 4], [f32; 2])> for Vertex { fn from((position, normal, uv): ([f32; 4], [f32; 4], [f32; 2])) -> Self { Vertex { - position: position, - normal: normal, - uv: uv, + position, + normal, + uv, } } } @@ -52,7 +52,7 @@ impl From<([f32; 3], [f32; 3], [f32; 2])> for Vertex { Vertex { position: [position[0], position[1], position[2], 1.0], normal: [normal[0], normal[1], normal[2], 0.0], - uv: uv, + uv, } } } diff --git a/src/serialization/world.rs b/src/serialization/world.rs index bafd5c5d14..0f4e4d9855 100644 --- a/src/serialization/world.rs +++ b/src/serialization/world.rs @@ -359,7 +359,7 @@ impl DeserializeImpl { .iter() .map(|reg| (reg.1.uuid, reg.1.clone())), ), - tag_types: tag_types, + tag_types, comp_types: component_types, // re-use the entity-uuid mapping entity_map: RefCell::new(HashMap::from_iter(