From 15f794b7a89efb3299cb85b392ec13af145fb0fd Mon Sep 17 00:00:00 2001 From: Poly Date: Mon, 4 Jul 2022 01:17:29 +0200 Subject: Address Clippy lints --- graphics/src/layer.rs | 4 ++-- graphics/src/widget/canvas/path.rs | 5 ++--- graphics/src/widget/canvas/path/builder.rs | 2 +- graphics/src/widget/qr_code.rs | 5 +---- 4 files changed, 6 insertions(+), 10 deletions(-) (limited to 'graphics') diff --git a/graphics/src/layer.rs b/graphics/src/layer.rs index 93506258..af545713 100644 --- a/graphics/src/layer.rs +++ b/graphics/src/layer.rs @@ -202,7 +202,7 @@ impl<'a> Layer<'a> { Self::process_primitive( layers, translation + *new_translation, - &content, + content, current_layer, ); } @@ -210,7 +210,7 @@ impl<'a> Layer<'a> { Self::process_primitive( layers, translation, - &cache, + cache, current_layer, ); } diff --git a/graphics/src/widget/canvas/path.rs b/graphics/src/widget/canvas/path.rs index 1728f060..47786224 100644 --- a/graphics/src/widget/canvas/path.rs +++ b/graphics/src/widget/canvas/path.rs @@ -74,7 +74,7 @@ impl Path { pub(super) fn dashed(path: &Path, line_dash: LineDash<'_>) -> Path { Path::new(|builder| { let segments_odd = (line_dash.segments.len() % 2 == 1).then(|| { - [&line_dash.segments[..], &line_dash.segments[..]].concat() + [line_dash.segments, line_dash.segments].concat() }); let mut draw_line = false; @@ -103,8 +103,7 @@ pub(super) fn dashed(path: &Path, line_dash: LineDash<'_>) -> Path { }, index: line_dash.offset, intervals: segments_odd - .as_ref() - .map(Vec::as_slice) + .as_deref() .unwrap_or(line_dash.segments), }, ); diff --git a/graphics/src/widget/canvas/path/builder.rs b/graphics/src/widget/canvas/path/builder.rs index d04dbdde..2f1f85a0 100644 --- a/graphics/src/widget/canvas/path/builder.rs +++ b/graphics/src/widget/canvas/path/builder.rs @@ -53,7 +53,7 @@ impl Builder { let _ = self.raw.line_to(a); } - let _ = self.raw.arc_to( + self.raw.arc_to( math::Vector::new(radius, radius), math::Angle::radians(0.0), path::ArcFlags::default(), diff --git a/graphics/src/widget/qr_code.rs b/graphics/src/widget/qr_code.rs index 1eb862ba..86a27fd0 100644 --- a/graphics/src/widget/qr_code.rs +++ b/graphics/src/widget/qr_code.rs @@ -67,10 +67,7 @@ where let side_length = (self.state.width + 2 * QUIET_ZONE) as f32 * f32::from(self.cell_size); - layout::Node::new(Size::new( - f32::from(side_length), - f32::from(side_length), - )) + layout::Node::new(Size::new(side_length, side_length)) } fn draw( -- cgit From 33a24b58210c88571f789ee27495e3ee3a55e3a4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 9 Jul 2022 17:05:45 +0200 Subject: Run `cargo fmt` --- graphics/src/widget/canvas/path.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'graphics') diff --git a/graphics/src/widget/canvas/path.rs b/graphics/src/widget/canvas/path.rs index 47786224..f834e286 100644 --- a/graphics/src/widget/canvas/path.rs +++ b/graphics/src/widget/canvas/path.rs @@ -73,9 +73,8 @@ impl Path { pub(super) fn dashed(path: &Path, line_dash: LineDash<'_>) -> Path { Path::new(|builder| { - let segments_odd = (line_dash.segments.len() % 2 == 1).then(|| { - [line_dash.segments, line_dash.segments].concat() - }); + let segments_odd = (line_dash.segments.len() % 2 == 1) + .then(|| [line_dash.segments, line_dash.segments].concat()); let mut draw_line = false; -- cgit From 2f76a10a1d3617e414fb33c0c6cd5cb7782197ad Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 9 Jul 2022 18:03:59 +0200 Subject: Fix further `clippy` lints ... and explicitly annotate crates as well. --- graphics/src/lib.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'graphics') diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs index 370f70d6..a7a1cabb 100644 --- a/graphics/src/lib.rs +++ b/graphics/src/lib.rs @@ -7,11 +7,19 @@ #![doc( html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg" )] -#![deny(missing_docs)] -#![deny(missing_debug_implementations)] -#![deny(unused_results)] -#![deny(unsafe_code)] +#![deny( + missing_debug_implementations, + missing_docs, + unsafe_code, + unused_results, + clippy::extra_unused_lifetimes, + clippy::from_over_into, + clippy::needless_borrow, + clippy::new_without_default, + clippy::useless_conversion +)] #![forbid(rust_2018_idioms)] +#![allow(clippy::inherent_to_string, clippy::type_complexity)] #![cfg_attr(docsrs, feature(doc_cfg))] mod antialiasing; mod error; -- cgit From 2065a40f642589134142a740ff4198deaa4c378b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 9 Jul 2022 18:42:41 +0200 Subject: Fix `clippy` lints for all crates and features ... and check those in CI as well! --- graphics/src/font/source.rs | 6 ++++++ graphics/src/widget/canvas/path/builder.rs | 6 ++++++ graphics/src/widget/pure/qr_code.rs | 8 ++++---- graphics/src/widget/qr_code.rs | 8 ++++---- graphics/src/window/gl_compositor.rs | 3 +++ 5 files changed, 23 insertions(+), 8 deletions(-) (limited to 'graphics') diff --git a/graphics/src/font/source.rs b/graphics/src/font/source.rs index a2d3f51d..c0b50e1d 100644 --- a/graphics/src/font/source.rs +++ b/graphics/src/font/source.rs @@ -37,3 +37,9 @@ impl Source { } } } + +impl Default for Source { + fn default() -> Self { + Self::new() + } +} diff --git a/graphics/src/widget/canvas/path/builder.rs b/graphics/src/widget/canvas/path/builder.rs index 2f1f85a0..05316d8a 100644 --- a/graphics/src/widget/canvas/path/builder.rs +++ b/graphics/src/widget/canvas/path/builder.rs @@ -151,3 +151,9 @@ impl Builder { } } } + +impl Default for Builder { + fn default() -> Self { + Self::new() + } +} diff --git a/graphics/src/widget/pure/qr_code.rs b/graphics/src/widget/pure/qr_code.rs index 23a8ceb6..bff391fe 100644 --- a/graphics/src/widget/pure/qr_code.rs +++ b/graphics/src/widget/pure/qr_code.rs @@ -53,12 +53,12 @@ where } } -impl<'a, Message, B, T> Into>> - for QRCode<'a> +impl<'a, Message, B, T> From> + for Element<'a, Message, Renderer> where B: Backend, { - fn into(self) -> Element<'a, Message, Renderer> { - Element::new(self) + fn from(qr_code: QRCode<'a>) -> Self { + Self::new(qr_code) } } diff --git a/graphics/src/widget/qr_code.rs b/graphics/src/widget/qr_code.rs index 86a27fd0..1a5c0b0a 100644 --- a/graphics/src/widget/qr_code.rs +++ b/graphics/src/widget/qr_code.rs @@ -125,13 +125,13 @@ where } } -impl<'a, Message, B, T> Into>> - for QRCode<'a> +impl<'a, Message, B, T> From> + for Element<'a, Message, Renderer> where B: Backend, { - fn into(self) -> Element<'a, Message, Renderer> { - Element::new(self) + fn from(qr_code: QRCode<'a>) -> Self { + Self::new(qr_code) } } diff --git a/graphics/src/window/gl_compositor.rs b/graphics/src/window/gl_compositor.rs index 4ff17366..722e4d9c 100644 --- a/graphics/src/window/gl_compositor.rs +++ b/graphics/src/window/gl_compositor.rs @@ -35,6 +35,9 @@ pub trait GLCompositor: Sized { /// Creates a new [`GLCompositor`] and [`Renderer`] with the given /// [`Settings`] and an OpenGL address loader function. /// + /// # Safety + /// The `loader_function` should resolve to valid OpenGL bindings. + /// /// [`Renderer`]: crate::Renderer /// [`Backend`]: crate::Backend /// [`Settings`]: Self::Settings -- cgit