Merge pull request #1379 from PolyMeilex/fix/clippy

Address Clippy lints
This commit is contained in:
Héctor Ramón 2022-07-09 19:03:40 +02:00 committed by GitHub
commit 9051dd6977
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
113 changed files with 606 additions and 509 deletions

View file

@ -37,3 +37,9 @@ impl Source {
}
}
}
impl Default for Source {
fn default() -> Self {
Self::new()
}
}

View file

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

View file

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

View file

@ -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;
@ -103,8 +102,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),
},
);

View file

@ -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(),
@ -151,3 +151,9 @@ impl Builder {
}
}
}
impl Default for Builder {
fn default() -> Self {
Self::new()
}
}

View file

@ -53,12 +53,12 @@ where
}
}
impl<'a, Message, B, T> Into<Element<'a, Message, Renderer<B, T>>>
for QRCode<'a>
impl<'a, Message, B, T> From<QRCode<'a>>
for Element<'a, Message, Renderer<B, T>>
where
B: Backend,
{
fn into(self) -> Element<'a, Message, Renderer<B, T>> {
Element::new(self)
fn from(qr_code: QRCode<'a>) -> Self {
Self::new(qr_code)
}
}

View file

@ -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(
@ -128,13 +125,13 @@ where
}
}
impl<'a, Message, B, T> Into<Element<'a, Message, Renderer<B, T>>>
for QRCode<'a>
impl<'a, Message, B, T> From<QRCode<'a>>
for Element<'a, Message, Renderer<B, T>>
where
B: Backend,
{
fn into(self) -> Element<'a, Message, Renderer<B, T>> {
Element::new(self)
fn from(qr_code: QRCode<'a>) -> Self {
Self::new(qr_code)
}
}

View file

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