From cbe9298a0b31c3af05e4515a74dd5d9f997e6af2 Mon Sep 17 00:00:00 2001 From: Kai Mast Date: Sat, 28 Mar 2020 15:25:55 -0700 Subject: [PATCH 01/10] Clippy --- native/src/widget/text_input/editor.rs | 5 ++--- src/executor.rs | 2 +- wgpu/src/renderer.rs | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/native/src/widget/text_input/editor.rs b/native/src/widget/text_input/editor.rs index 71c4f292..c9b9795d 100644 --- a/native/src/widget/text_input/editor.rs +++ b/native/src/widget/text_input/editor.rs @@ -54,8 +54,7 @@ impl<'a> Editor<'a> { if start > 0 { self.cursor.move_left(self.value); - - let _ = self.value.remove(start - 1); + self.value.remove(start - 1); } } } @@ -70,7 +69,7 @@ impl<'a> Editor<'a> { let end = self.cursor.end(self.value); if end < self.value.len() { - let _ = self.value.remove(end); + self.value.remove(end); } } } diff --git a/src/executor.rs b/src/executor.rs index b4be5264..2067ffac 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -36,7 +36,7 @@ mod platform { &self, future: impl futures::Future + Send + 'static, ) { - let _ = self.0.spawn(future); + self.0.spawn(future); } fn enter(&self, f: impl FnOnce() -> R) -> R { diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index c06af339..950c7693 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -103,8 +103,8 @@ impl Renderer { layers.push(Layer::new(Rectangle { x: 0, y: 0, - width: u32::from(width), - height: u32::from(height), + width, + height })); self.draw_primitive(Vector::new(0.0, 0.0), primitive, &mut layers); @@ -356,7 +356,7 @@ impl Renderer { ) { let bounds = layer.bounds * scale_factor; - if layer.meshes.len() > 0 { + if !layer.meshes.is_empty() { let scaled = transformation * Transformation::scale(scale_factor, scale_factor); @@ -372,7 +372,7 @@ impl Renderer { ); } - if layer.quads.len() > 0 { + if !layer.quads.is_empty() { self.quad_pipeline.draw( device, encoder, @@ -402,7 +402,7 @@ impl Renderer { } } - if layer.text.len() > 0 { + if !layer.text.is_empty() { for text in layer.text.iter() { // Target physical coordinates directly to avoid blurry text let text = wgpu_glyph::Section { From 442a52be0796eef848cef4ae849f83a5e3161a79 Mon Sep 17 00:00:00 2001 From: Kai Mast Date: Sat, 28 Mar 2020 15:30:51 -0700 Subject: [PATCH 02/10] Fix formatting --- wgpu/src/renderer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index 950c7693..6ceb4105 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -104,7 +104,7 @@ impl Renderer { x: 0, y: 0, width, - height + height, })); self.draw_primitive(Vector::new(0.0, 0.0), primitive, &mut layers); From f9b73607f59afd435eca0f06a1163ad826806386 Mon Sep 17 00:00:00 2001 From: Kai Mast Date: Sat, 28 Mar 2020 15:36:07 -0700 Subject: [PATCH 03/10] Fix lint --- src/executor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/executor.rs b/src/executor.rs index 2067ffac..b4be5264 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -36,7 +36,7 @@ mod platform { &self, future: impl futures::Future + Send + 'static, ) { - self.0.spawn(future); + let _ = self.0.spawn(future); } fn enter(&self, f: impl FnOnce() -> R) -> R { From 3f7dd5059454d956373c0ec29e87cb278f3f9df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 29 Mar 2020 15:04:11 +0200 Subject: [PATCH 04/10] Use `!is_empty()` instead of `len() > 0` --- wgpu/src/renderer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index 6ceb4105..e847cb64 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -386,7 +386,7 @@ impl Renderer { #[cfg(any(feature = "image", feature = "svg"))] { - if layer.images.len() > 0 { + if !layer.images.is_empty() { let scaled = transformation * Transformation::scale(scale_factor, scale_factor); From 49bcebb1e5de9957bd0a9d7274371e3550569fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 29 Mar 2020 15:16:36 +0200 Subject: [PATCH 05/10] Remove unnecessary merge of `iced_wgpu::Defaults` --- wgpu/src/renderer/widget/button.rs | 3 +-- wgpu/src/renderer/widget/container.rs | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/wgpu/src/renderer/widget/button.rs b/wgpu/src/renderer/widget/button.rs index 0de5bf5c..359b4866 100644 --- a/wgpu/src/renderer/widget/button.rs +++ b/wgpu/src/renderer/widget/button.rs @@ -10,7 +10,7 @@ impl iced_native::button::Renderer for Renderer { fn draw( &mut self, - defaults: &Defaults, + _defaults: &Defaults, bounds: Rectangle, cursor_position: Point, is_disabled: bool, @@ -39,7 +39,6 @@ impl iced_native::button::Renderer for Renderer { text: defaults::Text { color: styling.text_color, }, - ..*defaults }, content_layout, cursor_position, diff --git a/wgpu/src/renderer/widget/container.rs b/wgpu/src/renderer/widget/container.rs index 2d4d1db8..dda7dc8a 100644 --- a/wgpu/src/renderer/widget/container.rs +++ b/wgpu/src/renderer/widget/container.rs @@ -19,7 +19,6 @@ impl iced_native::container::Renderer for Renderer { text: defaults::Text { color: style.text_color.unwrap_or(defaults.text.color), }, - ..*defaults }; let (content, mouse_cursor) = From 8b49968cabe46c4255a101105748394d55bc23a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 29 Mar 2020 15:20:44 +0200 Subject: [PATCH 06/10] Remove redundant field assignment --- wgpu/src/renderer/widget/checkbox.rs | 2 +- wgpu/src/triangle/msaa.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wgpu/src/renderer/widget/checkbox.rs b/wgpu/src/renderer/widget/checkbox.rs index 1a0585d3..ecacf1de 100644 --- a/wgpu/src/renderer/widget/checkbox.rs +++ b/wgpu/src/renderer/widget/checkbox.rs @@ -38,7 +38,7 @@ impl checkbox::Renderer for Renderer { content: crate::text::CHECKMARK_ICON.to_string(), font: crate::text::BUILTIN_ICONS, size: bounds.height * 0.7, - bounds: bounds, + bounds, color: style.checkmark_color, horizontal_alignment: HorizontalAlignment::Center, vertical_alignment: VerticalAlignment::Center, diff --git a/wgpu/src/triangle/msaa.rs b/wgpu/src/triangle/msaa.rs index 7ccfb062..f65f0a00 100644 --- a/wgpu/src/triangle/msaa.rs +++ b/wgpu/src/triangle/msaa.rs @@ -120,7 +120,7 @@ impl Blit { format, pipeline, constants: constant_bind_group, - texture_layout: texture_layout, + texture_layout, sample_count: antialiasing.sample_count(), targets: None, } From 79fed3d69552011a0a5c2585892bb685e7657ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 29 Mar 2020 15:21:18 +0200 Subject: [PATCH 07/10] Remove unnecessary conversion in `iced_wgpu` --- wgpu/src/renderer/widget/text_input.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wgpu/src/renderer/widget/text_input.rs b/wgpu/src/renderer/widget/text_input.rs index 170ac3c5..9093b0c6 100644 --- a/wgpu/src/renderer/widget/text_input.rs +++ b/wgpu/src/renderer/widget/text_input.rs @@ -106,8 +106,7 @@ impl text_input::Renderer for Renderer { style_sheet.placeholder_color() } else { style_sheet.value_color() - } - .into(), + }, font, bounds: Rectangle { width: f32::INFINITY, From 9e139e6ca789d48ebcc1f3f0c14ad957713ec52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 29 Mar 2020 15:21:43 +0200 Subject: [PATCH 08/10] Improve `Antialiasing::sample_count` signature --- wgpu/src/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu/src/settings.rs b/wgpu/src/settings.rs index f946ce0d..5ee245b6 100644 --- a/wgpu/src/settings.rs +++ b/wgpu/src/settings.rs @@ -45,7 +45,7 @@ pub enum Antialiasing { } impl Antialiasing { - pub(crate) fn sample_count(&self) -> u32 { + pub(crate) fn sample_count(self) -> u32 { match self { Antialiasing::MSAAx2 => 2, Antialiasing::MSAAx4 => 4, From 3f6c6b7b029730e01bd18480f162a2eae692744f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 29 Mar 2020 15:22:17 +0200 Subject: [PATCH 09/10] Remove unnecessary `clone` call in `Transformation` --- wgpu/src/transformation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu/src/transformation.rs b/wgpu/src/transformation.rs index 666696f3..c991f330 100644 --- a/wgpu/src/transformation.rs +++ b/wgpu/src/transformation.rs @@ -49,6 +49,6 @@ impl AsRef<[f32; 16]> for Transformation { impl From for [f32; 16] { fn from(t: Transformation) -> [f32; 16] { - t.as_ref().clone() + *t.as_ref() } } From 01bc95c2a3dcaf0c2916a2d2891094e1dc1e11e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 29 Mar 2020 15:22:56 +0200 Subject: [PATCH 10/10] Remove redundant closure in `Application::run` --- winit/src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winit/src/application.rs b/winit/src/application.rs index a647a1b6..b9d5fed8 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -123,7 +123,7 @@ pub trait Application: Sized { Runtime::new(executor, Proxy::new(event_loop.create_proxy())) }; - let (mut application, init_command) = runtime.enter(|| Self::new()); + let (mut application, init_command) = runtime.enter(Self::new); runtime.spawn(init_command); let subscription = application.subscription();