From c87c1cd79509ae4beac970060c36422e1440464d Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Mon, 21 Feb 2022 20:11:43 +0100 Subject: [PATCH] Fix some clippy lints Signed-off-by: Daniel Egger --- src/camera.rs | 2 +- src/graphics/config_ui.rs | 2 +- src/graphics/pipelines.rs | 2 +- src/graphics/renderer.rs | 7 ++----- src/input/handler.rs | 2 +- src/kernel/topology/faces.rs | 4 ++-- src/main.rs | 2 +- src/math/scalar.rs | 2 +- src/model.rs | 2 +- 9 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index f612eb92e..d25f75b4f 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -132,7 +132,7 @@ impl Camera { &self, window: &Window, cursor: Option>, - triangles: &Vec, + triangles: &[Triangle], ) -> FocusPoint { let cursor = match cursor { Some(cursor) => cursor, diff --git a/src/graphics/config_ui.rs b/src/graphics/config_ui.rs index 77bbb439f..380ecdc7c 100644 --- a/src/graphics/config_ui.rs +++ b/src/graphics/config_ui.rs @@ -88,7 +88,7 @@ impl ConfigUi { // - @hannobraun &mut StagingBelt::new(1024), encoder, - &view, + view, surface_config.width, surface_config.height, )?; diff --git a/src/graphics/pipelines.rs b/src/graphics/pipelines.rs index 61ba9867c..cba6fb867 100644 --- a/src/graphics/pipelines.rs +++ b/src/graphics/pipelines.rs @@ -87,7 +87,7 @@ impl Pipeline { front_face: wgpu::FrontFace::Ccw, cull_mode: None, unclipped_depth: false, - polygon_mode: polygon_mode, + polygon_mode, conservative: false, }, depth_stencil: Some(wgpu::DepthStencilState { diff --git a/src/graphics/renderer.rs b/src/graphics/renderer.rs index 4c293ca1d..4c5f98a5c 100644 --- a/src/graphics/renderer.rs +++ b/src/graphics/renderer.rs @@ -175,7 +175,6 @@ impl Renderer { let uniforms = Uniforms { transform: Transform::for_vertices(camera, aspect_ratio), transform_normals: Transform::for_normals(camera), - ..Uniforms::default() }; self.queue.write_buffer( @@ -231,7 +230,7 @@ impl Renderer { &self.geometries.aabb, config, ) - .map_err(|err| DrawError::Text(err))?; + .map_err(DrawError::Text)?; let command_buffer = encoder.finish(); self.queue.submit(Some(command_buffer)); @@ -261,9 +260,7 @@ impl Renderer { usage: wgpu::TextureUsages::RENDER_ATTACHMENT, }); - let view = texture.create_view(&wgpu::TextureViewDescriptor::default()); - - view + texture.create_view(&wgpu::TextureViewDescriptor::default()) } fn clear_views( diff --git a/src/input/handler.rs b/src/input/handler.rs index 53f44cfd5..c4574bbe4 100644 --- a/src/input/handler.rs +++ b/src/input/handler.rs @@ -121,7 +121,7 @@ impl Handler { now: Instant, camera: &mut Camera, window: &Window, - triangles: &Vec, + triangles: &[Triangle], ) { let focus_point = camera.focus_point(window, self.cursor, triangles); diff --git a/src/kernel/topology/faces.rs b/src/kernel/topology/faces.rs index 051189787..4ed163035 100644 --- a/src/kernel/topology/faces.rs +++ b/src/kernel/topology/faces.rs @@ -103,7 +103,7 @@ impl Face { ) { match self { Self::Face { edges, surface } => { - let approx = Approximation::for_edges(&edges, tolerance); + let approx = Approximation::for_edges(edges, tolerance); approx.validate().expect("Invalid approximation"); let points: Vec<_> = approx @@ -195,7 +195,7 @@ impl Face { let intersection = edge .to_parry() .cast_local_ray(&ray, f64::INFINITY, true) - .map(|t| Scalar::from_f64(t)); + .map(Scalar::from_f64); if let Some(t) = intersection { // Due to slight inaccuracies, we might get diff --git a/src/main.rs b/src/main.rs index 30551ba49..bc0fe14ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,7 @@ fn main() -> anyhow::Result<()> { let mut parameters = HashMap::new(); for parameter in args.parameters { - let mut parameter = parameter.splitn(2, "="); + let mut parameter = parameter.splitn(2, '='); let key = parameter .next() diff --git a/src/math/scalar.rs b/src/math/scalar.rs index fae6d94d2..168b76da3 100644 --- a/src/math/scalar.rs +++ b/src/math/scalar.rs @@ -123,7 +123,7 @@ impl Ord for Scalar { fn cmp(&self, other: &Self) -> cmp::Ordering { // Should never panic, as `from_f64` checks that the wrapped value is // finite. - self.partial_cmp(&other).unwrap() + self.partial_cmp(other).unwrap() } } diff --git a/src/model.rs b/src/model.rs index d8d8dca09..e9a979b33 100644 --- a/src/model.rs +++ b/src/model.rs @@ -70,7 +70,7 @@ impl Model { let shape = unsafe { let lib = libloading::Library::new(self.lib_path())?; let model: libloading::Symbol = lib.get(b"model")?; - model(&arguments) + model(arguments) }; Ok(shape)