summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Poly <marynczakbartlomiej@gmail.com>2022-07-04 01:17:29 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-09 17:07:38 +0200
commit15f794b7a89efb3299cb85b392ec13af145fb0fd (patch)
tree39d8c740168e4c09e15538451ba7f3899051ad43
parente053e25d2ccb17f7a162685a106a8bbd915a873f (diff)
downloadiced-15f794b7a89efb3299cb85b392ec13af145fb0fd.tar.gz
iced-15f794b7a89efb3299cb85b392ec13af145fb0fd.tar.bz2
iced-15f794b7a89efb3299cb85b392ec13af145fb0fd.zip
Address Clippy lints
-rw-r--r--clippy.toml1
-rw-r--r--futures/src/subscription.rs6
-rw-r--r--futures/src/subscription/tracker.rs2
-rw-r--r--glow/src/program.rs2
-rw-r--r--glow/src/quad/compatibility.rs10
-rw-r--r--glow/src/quad/core.rs2
-rw-r--r--glow/src/text.rs5
-rw-r--r--graphics/src/layer.rs4
-rw-r--r--graphics/src/widget/canvas/path.rs5
-rw-r--r--graphics/src/widget/canvas/path/builder.rs2
-rw-r--r--graphics/src/widget/qr_code.rs5
-rw-r--r--native/src/hasher.rs8
-rw-r--r--native/src/overlay/menu.rs22
-rw-r--r--native/src/program/state.rs2
-rw-r--r--native/src/user_interface.rs2
-rw-r--r--native/src/widget/checkbox.rs5
-rw-r--r--native/src/widget/pane_grid.rs3
-rw-r--r--native/src/widget/pane_grid/node.rs20
-rw-r--r--native/src/widget/pane_grid/state.rs5
-rw-r--r--native/src/widget/pick_list.rs13
-rw-r--r--native/src/widget/radio.rs8
-rw-r--r--native/src/widget/rule.rs2
-rw-r--r--native/src/widget/slider.rs4
-rw-r--r--native/src/widget/text.rs4
-rw-r--r--native/src/widget/text_input.rs22
-rw-r--r--native/src/widget/text_input/editor.rs19
-rw-r--r--native/src/widget/text_input/value.rs7
-rw-r--r--native/src/widget/toggler.rs7
-rw-r--r--pure/src/lib.rs2
-rw-r--r--pure/src/widget/pick_list.rs4
-rw-r--r--wgpu/src/backend.rs2
-rw-r--r--wgpu/src/image.rs8
-rw-r--r--wgpu/src/image/atlas.rs2
-rw-r--r--wgpu/src/image/atlas/layer.rs5
-rw-r--r--wgpu/src/image/raster.rs2
-rw-r--r--wgpu/src/image/vector.rs4
-rw-r--r--wgpu/src/text.rs3
-rw-r--r--wgpu/src/triangle.rs74
-rw-r--r--wgpu/src/triangle/msaa.rs4
-rw-r--r--wgpu/src/window/compositor.rs2
-rw-r--r--winit/src/application.rs2
-rw-r--r--winit/src/conversion.rs8
-rw-r--r--winit/src/system.rs2
43 files changed, 148 insertions, 173 deletions
diff --git a/clippy.toml b/clippy.toml
new file mode 100644
index 00000000..0d4e02f0
--- /dev/null
+++ b/clippy.toml
@@ -0,0 +1 @@
+too-many-arguments-threshold = 20
diff --git a/futures/src/subscription.rs b/futures/src/subscription.rs
index 0085886d..0479c63c 100644
--- a/futures/src/subscription.rs
+++ b/futures/src/subscription.rs
@@ -183,11 +183,7 @@ where
let mapper = self.mapper;
- Box::pin(
- self.recipe
- .stream(input)
- .map(move |element| mapper(element)),
- )
+ Box::pin(self.recipe.stream(input).map(mapper))
}
}
diff --git a/futures/src/subscription/tracker.rs b/futures/src/subscription/tracker.rs
index 2cf98284..5717fdb9 100644
--- a/futures/src/subscription/tracker.rs
+++ b/futures/src/subscription/tracker.rs
@@ -127,7 +127,7 @@ where
futures.push(Box::pin(future));
}
- self.subscriptions.retain(|id, _| alive.contains(&id));
+ self.subscriptions.retain(|id, _| alive.contains(id));
futures
}
diff --git a/glow/src/program.rs b/glow/src/program.rs
index 9a02d578..1eb9c535 100644
--- a/glow/src/program.rs
+++ b/glow/src/program.rs
@@ -70,7 +70,7 @@ impl Shader {
unsafe {
let shader = gl.create_shader(stage).expect("Cannot create shader");
- gl.shader_source(shader, &content);
+ gl.shader_source(shader, content);
gl.compile_shader(shader);
if !gl.get_shader_compile_status(shader) {
diff --git a/glow/src/quad/compatibility.rs b/glow/src/quad/compatibility.rs
index 76f98ab7..7224e206 100644
--- a/glow/src/quad/compatibility.rs
+++ b/glow/src/quad/compatibility.rs
@@ -110,10 +110,8 @@ impl Pipeline {
bounds: Rectangle<u32>,
) {
// TODO: Remove this allocation (probably by changing the shader and removing the need of two `position`)
- let vertices: Vec<Vertex> = instances
- .iter()
- .flat_map(|quad| Vertex::from_quad(quad))
- .collect();
+ let vertices: Vec<Vertex> =
+ instances.iter().flat_map(Vertex::from_quad).collect();
// TODO: Remove this allocation (or allocate only when needed)
let indices: Vec<i32> = (0..instances.len().min(MAX_QUADS) as i32)
@@ -187,13 +185,13 @@ impl Pipeline {
gl.buffer_sub_data_u8_slice(
glow::ARRAY_BUFFER,
0,
- bytemuck::cast_slice(&vertices),
+ bytemuck::cast_slice(vertices),
);
gl.buffer_sub_data_u8_slice(
glow::ELEMENT_ARRAY_BUFFER,
0,
- bytemuck::cast_slice(&indices),
+ bytemuck::cast_slice(indices),
);
gl.draw_elements(
diff --git a/glow/src/quad/core.rs b/glow/src/quad/core.rs
index f37300f6..3e51b1ca 100644
--- a/glow/src/quad/core.rs
+++ b/glow/src/quad/core.rs
@@ -154,7 +154,7 @@ impl Pipeline {
gl.buffer_sub_data_u8_slice(
glow::ARRAY_BUFFER,
0,
- bytemuck::cast_slice(&instances),
+ bytemuck::cast_slice(instances),
);
gl.draw_arrays_instanced(
diff --git a/glow/src/text.rs b/glow/src/text.rs
index 0d45d61b..37ccdece 100644
--- a/glow/src/text.rs
+++ b/glow/src/text.rs
@@ -54,7 +54,7 @@ impl Pipeline {
#[cfg(target_arch = "wasm32")]
let draw_brush_builder = draw_brush_builder.draw_cache_align_4x4(true);
- let draw_brush = draw_brush_builder.build(&gl);
+ let draw_brush = draw_brush_builder.build(gl);
let measure_brush =
glyph_brush::GlyphBrushBuilder::using_font(font).build();
@@ -180,7 +180,8 @@ impl Pipeline {
}
b_count += utf8_len;
}
- return byte_index;
+
+ byte_index
};
if !nearest_only {
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(
diff --git a/native/src/hasher.rs b/native/src/hasher.rs
index 9f6aacce..fa52f16d 100644
--- a/native/src/hasher.rs
+++ b/native/src/hasher.rs
@@ -1,13 +1,7 @@
/// The hasher used to compare layouts.
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct Hasher(twox_hash::XxHash64);
-impl Default for Hasher {
- fn default() -> Self {
- Hasher(twox_hash::XxHash64::default())
- }
-}
-
impl core::hash::Hasher for Hasher {
fn write(&mut self, bytes: &[u8]) {
self.0.write(bytes)
diff --git a/native/src/overlay/menu.rs b/native/src/overlay/menu.rs
index 979a13c3..0c25200c 100644
--- a/native/src/overlay/menu.rs
+++ b/native/src/overlay/menu.rs
@@ -174,9 +174,9 @@ where
Self {
container,
- width: width,
+ width,
target_height,
- style: style,
+ style,
}
}
}
@@ -230,7 +230,7 @@ where
shell: &mut Shell<'_, Message>,
) -> event::Status {
self.container.on_event(
- event.clone(),
+ event,
layout,
cursor_position,
renderer,
@@ -326,7 +326,8 @@ where
use std::f32;
let limits = limits.width(Length::Fill).height(Length::Shrink);
- let text_size = self.text_size.unwrap_or(renderer.default_size());
+ let text_size =
+ self.text_size.unwrap_or_else(|| renderer.default_size());
let size = {
let intrinsic = Size::new(
@@ -366,8 +367,9 @@ where
let bounds = layout.bounds();
if bounds.contains(cursor_position) {
- let text_size =
- self.text_size.unwrap_or(renderer.default_size());
+ let text_size = self
+ .text_size
+ .unwrap_or_else(|| renderer.default_size());
*self.hovered_option = Some(
((cursor_position.y - bounds.y)
@@ -380,8 +382,9 @@ where
let bounds = layout.bounds();
if bounds.contains(cursor_position) {
- let text_size =
- self.text_size.unwrap_or(renderer.default_size());
+ let text_size = self
+ .text_size
+ .unwrap_or_else(|| renderer.default_size());
*self.hovered_option = Some(
((cursor_position.y - bounds.y)
@@ -430,7 +433,8 @@ where
let appearance = theme.appearance(self.style);
let bounds = layout.bounds();
- let text_size = self.text_size.unwrap_or(renderer.default_size());
+ let text_size =
+ self.text_size.unwrap_or_else(|| renderer.default_size());
let option_height = (text_size + self.padding.vertical()) as usize;
let offset = viewport.y - bounds.y;
diff --git a/native/src/program/state.rs b/native/src/program/state.rs
index 7ec2a04f..2ddde2c2 100644
--- a/native/src/program/state.rs
+++ b/native/src/program/state.rs
@@ -113,7 +113,7 @@ where
&mut messages,
);
- messages.extend(self.queued_messages.drain(..));
+ messages.append(&mut self.queued_messages);
self.queued_events.clear();
debug.event_processing_finished();
diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs
index 97a004e7..ef6f437e 100644
--- a/native/src/user_interface.rs
+++ b/native/src/user_interface.rs
@@ -430,7 +430,7 @@ where
overlay
.as_ref()
.and_then(|layout| {
- root.overlay(Layout::new(&base), renderer).map(|overlay| {
+ root.overlay(Layout::new(base), renderer).map(|overlay| {
let overlay_interaction = overlay.mouse_interaction(
Layout::new(layout),
cursor_position,
diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs
index 9e7f183a..a49d2fa2 100644
--- a/native/src/widget/checkbox.rs
+++ b/native/src/widget/checkbox.rs
@@ -158,7 +158,10 @@ where
Text::new(&self.label)
.font(self.font.clone())
.width(self.width)
- .size(self.text_size.unwrap_or(renderer.default_size())),
+ .size(
+ self.text_size
+ .unwrap_or_else(|| renderer.default_size()),
+ ),
)
.layout(renderer, limits)
}
diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs
index eb969dbf..70ca772c 100644
--- a/native/src/widget/pane_grid.rs
+++ b/native/src/widget/pane_grid.rs
@@ -835,8 +835,7 @@ fn hovered_split<'a>(
) -> Option<(Split, Axis, Rectangle)> {
splits
.filter_map(|(split, (axis, region, ratio))| {
- let bounds =
- axis.split_line_bounds(*region, *ratio, f32::from(spacing));
+ let bounds = axis.split_line_bounds(*region, *ratio, spacing);
if bounds.contains(cursor_position) {
Some((*split, *axis, bounds))
diff --git a/native/src/widget/pane_grid/node.rs b/native/src/widget/pane_grid/node.rs
index af6573a0..cc304b96 100644
--- a/native/src/widget/pane_grid/node.rs
+++ b/native/src/widget/pane_grid/node.rs
@@ -36,14 +36,11 @@ impl Node {
std::iter::from_fn(move || {
while let Some(node) = unvisited_nodes.pop() {
- match node {
- Node::Split { id, a, b, .. } => {
- unvisited_nodes.push(a);
- unvisited_nodes.push(b);
+ if let Node::Split { id, a, b, .. } = node {
+ unvisited_nodes.push(a);
+ unvisited_nodes.push(b);
- return Some(id);
- }
- _ => {}
+ return Some(id);
}
}
@@ -124,12 +121,9 @@ impl Node {
}
pub(crate) fn update(&mut self, f: &impl Fn(&mut Node)) {
- match self {
- Node::Split { a, b, .. } => {
- a.update(f);
- b.update(f);
- }
- _ => {}
+ if let Node::Split { a, b, .. } = self {
+ a.update(f);
+ b.update(f);
}
f(self);
diff --git a/native/src/widget/pane_grid/state.rs b/native/src/widget/pane_grid/state.rs
index 6a282d24..4e90f645 100644
--- a/native/src/widget/pane_grid/state.rs
+++ b/native/src/widget/pane_grid/state.rs
@@ -66,6 +66,11 @@ impl<T> State<T> {
self.panes.len()
}
+ /// Returns `true` if the amount of panes in the [`State`] is 0.
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
+
/// Returns the internal state of the given [`Pane`], if it exists.
pub fn get(&self, pane: &Pane) -> Option<&T> {
self.panes.get(pane)
diff --git a/native/src/widget/pick_list.rs b/native/src/widget/pick_list.rs
index c6cfcc01..e735151e 100644
--- a/native/src/widget/pick_list.rs
+++ b/native/src/widget/pick_list.rs
@@ -160,7 +160,7 @@ where
let limits = limits.width(width).height(Length::Shrink).pad(padding);
- let text_size = text_size.unwrap_or(renderer.default_size());
+ let text_size = text_size.unwrap_or_else(|| renderer.default_size());
let max_width = match width {
Length::Shrink => {
@@ -407,10 +407,9 @@ pub fn draw<T, Renderer>(
let label = selected.map(ToString::to_string);
- if let Some(label) =
- label.as_ref().map(String::as_str).or_else(|| placeholder)
- {
- let text_size = f32::from(text_size.unwrap_or(renderer.default_size()));
+ if let Some(label) = label.as_deref().or(placeholder) {
+ let text_size =
+ f32::from(text_size.unwrap_or_else(|| renderer.default_size()));
renderer.fill_text(Text {
content: label,
@@ -460,7 +459,7 @@ where
self.padding,
self.text_size,
&self.font,
- self.placeholder.as_ref().map(String::as_str),
+ self.placeholder.as_deref(),
&self.options,
)
}
@@ -513,7 +512,7 @@ where
self.padding,
self.text_size,
&self.font,
- self.placeholder.as_ref().map(String::as_str),
+ self.placeholder.as_deref(),
self.selected.as_ref(),
self.style,
)
diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs
index ba45a0f4..647e3c5a 100644
--- a/native/src/widget/radio.rs
+++ b/native/src/widget/radio.rs
@@ -168,11 +168,9 @@ where
.width(Length::Units(self.size))
.height(Length::Units(self.size)),
)
- .push(
- Text::new(&self.label)
- .width(self.width)
- .size(self.text_size.unwrap_or(renderer.default_size())),
- )
+ .push(Text::new(&self.label).width(self.width).size(
+ self.text_size.unwrap_or_else(|| renderer.default_size()),
+ ))
.layout(renderer, limits)
}
diff --git a/native/src/widget/rule.rs b/native/src/widget/rule.rs
index 26285df4..f0fda8a9 100644
--- a/native/src/widget/rule.rs
+++ b/native/src/widget/rule.rs
@@ -36,7 +36,7 @@ where
/// Creates a vertical [`Rule`] with the given width.
pub fn vertical(width: u16) -> Self {
Rule {
- width: Length::from(Length::Units(width)),
+ width: Length::Units(width),
height: Length::Fill,
is_horizontal: false,
style: Default::default(),
diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs
index bda31327..c75c1e99 100644
--- a/native/src/widget/slider.rs
+++ b/native/src/widget/slider.rs
@@ -303,7 +303,7 @@ pub fn draw<T, R>(
HandleShape::Rectangle {
width,
border_radius,
- } => (f32::from(width), f32::from(bounds.height), border_radius),
+ } => (f32::from(width), bounds.height, border_radius),
};
let value = value.into() as f32;
@@ -447,7 +447,7 @@ where
_viewport: &Rectangle,
_renderer: &Renderer,
) -> mouse::Interaction {
- mouse_interaction(layout, cursor_position, &self.state)
+ mouse_interaction(layout, cursor_position, self.state)
}
}
diff --git a/native/src/widget/text.rs b/native/src/widget/text.rs
index 242247b0..8d173b8a 100644
--- a/native/src/widget/text.rs
+++ b/native/src/widget/text.rs
@@ -131,7 +131,7 @@ where
) -> layout::Node {
let limits = limits.width(self.width).height(self.height);
- let size = self.size.unwrap_or(renderer.default_size());
+ let size = self.size.unwrap_or_else(|| renderer.default_size());
let bounds = limits.max();
@@ -205,7 +205,7 @@ pub fn draw<Renderer>(
renderer.fill_text(crate::text::Text {
content,
- size: f32::from(size.unwrap_or(renderer.default_size())),
+ size: f32::from(size.unwrap_or_else(|| renderer.default_size())),
bounds: Rectangle { x, y, ..bounds },
color: appearance.color.unwrap_or(style.text_color),
font,
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs
index d345cec3..835b2b4d 100644
--- a/native/src/widget/text_input.rs
+++ b/native/src/widget/text_input.rs
@@ -198,7 +198,7 @@ pub fn layout<Renderer>(
where
Renderer: text::Renderer,
{
- let text_size = size.unwrap_or(renderer.default_size());
+ let text_size = size.unwrap_or_else(|| renderer.default_size());
let limits = limits
.pad(padding)
@@ -498,7 +498,7 @@ where
None => {
let content: String = clipboard
.read()
- .unwrap_or(String::new())
+ .unwrap_or_default()
.chars()
.filter(|c| !c.is_control())
.collect();
@@ -597,7 +597,7 @@ pub fn draw<Renderer>(
Renderer::Theme: StyleSheet,
{
let secure_value = is_secure.then(|| value.secure());
- let value = secure_value.as_ref().unwrap_or(&value);
+ let value = secure_value.as_ref().unwrap_or(value);
let bounds = layout.bounds();
let text_bounds = layout.children().next().unwrap().bounds();
@@ -623,16 +623,16 @@ pub fn draw<Renderer>(
);
let text = value.to_string();
- let size = size.unwrap_or(renderer.default_size());
+ let size = size.unwrap_or_else(|| renderer.default_size());
let (cursor, offset) = if state.is_focused() {
- match state.cursor.state(&value) {
+ match state.cursor.state(value) {
cursor::State::Index(position) => {
let (text_value_width, offset) =
measure_cursor_and_scroll_offset(
renderer,
text_bounds,
- &value,
+ value,
size,
position,
font.clone(),
@@ -664,7 +664,7 @@ pub fn draw<Renderer>(
measure_cursor_and_scroll_offset(
renderer,
text_bounds,
- &value,
+ value,
size,
left,
font.clone(),
@@ -674,7 +674,7 @@ pub fn draw<Renderer>(
measure_cursor_and_scroll_offset(
renderer,
text_bounds,
- &value,
+ value,
size,
right,
font.clone(),
@@ -998,16 +998,16 @@ fn find_cursor_position<Renderer>(
where
Renderer: text::Renderer,
{
- let size = size.unwrap_or(renderer.default_size());
+ let size = size.unwrap_or_else(|| renderer.default_size());
let offset =
- offset(renderer, text_bounds, font.clone(), size, &value, &state);
+ offset(renderer, text_bounds, font.clone(), size, value, state);
renderer
.hit_test(
&value.to_string(),
size.into(),
- font.clone(),
+ font,
Size::INFINITY,
Point::new(x + offset, text_bounds.height / 2.0),
true,
diff --git a/native/src/widget/text_input/editor.rs b/native/src/widget/text_input/editor.rs
index bac530e1..d53fa8d9 100644
--- a/native/src/widget/text_input/editor.rs
+++ b/native/src/widget/text_input/editor.rs
@@ -15,12 +15,9 @@ impl<'a> Editor<'a> {
}
pub fn insert(&mut self, character: char) {
- match self.cursor.selection(self.value) {
- Some((left, right)) => {
- self.cursor.move_left(self.value);
- self.value.remove_many(left, right);
- }
- _ => {}
+ if let Some((left, right)) = self.cursor.selection(self.value) {
+ self.cursor.move_left(self.value);
+ self.value.remove_many(left, right);
}
self.value.insert(self.cursor.end(self.value), character);
@@ -29,13 +26,9 @@ impl<'a> Editor<'a> {
pub fn paste(&mut self, content: Value) {
let length = content.len();
-
- match self.cursor.selection(self.value) {
- Some((left, right)) => {
- self.cursor.move_left(self.value);
- self.value.remove_many(left, right);
- }
- _ => {}
+ if let Some((left, right)) = self.cursor.selection(self.value) {
+ self.cursor.move_left(self.value);
+ self.value.remove_many(left, right);
}
self.value.insert_many(self.cursor.end(self.value), content);
diff --git a/native/src/widget/text_input/value.rs b/native/src/widget/text_input/value.rs
index 2034cca4..cf4da562 100644
--- a/native/src/widget/text_input/value.rs
+++ b/native/src/widget/text_input/value.rs
@@ -37,7 +37,7 @@ impl Value {
let previous_string =
&self.graphemes[..index.min(self.graphemes.len())].concat();
- UnicodeSegmentation::split_word_bound_indices(&previous_string as &str)
+ UnicodeSegmentation::split_word_bound_indices(previous_string as &str)
.filter(|(_, word)| !word.trim_start().is_empty())
.next_back()
.map(|(i, previous_word)| {
@@ -58,9 +58,8 @@ impl Value {
pub fn next_end_of_word(&self, index: usize) -> usize {
let next_string = &self.graphemes[index..].concat();
- UnicodeSegmentation::split_word_bound_indices(&next_string as &str)
- .filter(|(_, word)| !word.trim_start().is_empty())
- .next()
+ UnicodeSegmentation::split_word_bound_indices(next_string as &str)
+ .find(|(_, word)| !word.trim_start().is_empty())
.map(|(i, next_word)| {
index
+ UnicodeSegmentation::graphemes(next_word, true).count()
diff --git a/native/src/widget/toggler.rs b/native/src/widget/toggler.rs
index 0936c271..3deaf287 100644
--- a/native/src/widget/toggler.rs
+++ b/native/src/widget/toggler.rs
@@ -162,7 +162,10 @@ where
.horizontal_alignment(self.text_alignment)
.font(self.font.clone())
.width(self.width)
- .size(self.text_size.unwrap_or(renderer.default_size())),
+ .size(
+ self.text_size
+ .unwrap_or_else(|| renderer.default_size()),
+ ),
);
}
@@ -239,7 +242,7 @@ where
renderer,
style,
label_layout,
- &label,
+ label,
self.text_size,
self.font.clone(),
Default::default(),
diff --git a/pure/src/lib.rs b/pure/src/lib.rs
index 95aa3098..49b23e1b 100644
--- a/pure/src/lib.rs
+++ b/pure/src/lib.rs
@@ -146,7 +146,7 @@ where
content: impl Into<Element<'a, Message, Renderer>>,
) -> Self {
let element = content.into();
- let _ = state.diff(&element);
+ state.diff(&element);
Self { state, element }
}
diff --git a/pure/src/widget/pick_list.rs b/pure/src/widget/pick_list.rs
index 2c465932..bba5391a 100644
--- a/pure/src/widget/pick_list.rs
+++ b/pure/src/widget/pick_list.rs
@@ -143,7 +143,7 @@ where
self.padding,
self.text_size,
&self.font,
- self.placeholder.as_ref().map(String::as_str),
+ self.placeholder.as_deref(),
&self.options,
)
}
@@ -199,7 +199,7 @@ where
self.padding,
self.text_size,
&self.font,
- self.placeholder.as_ref().map(String::as_str),
+ self.placeholder.as_deref(),
self.selected.as_ref(),
self.style,
)
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs
index 05b4af9b..b0aa13fe 100644
--- a/wgpu/src/backend.rs
+++ b/wgpu/src/backend.rs
@@ -93,7 +93,7 @@ impl Backend {
&layer,
staging_belt,
encoder,
- &frame,
+ frame,
target_size.width,
target_size.height,
);
diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs
index 750ad62a..d964aed7 100644
--- a/wgpu/src/image.rs
+++ b/wgpu/src/image.rs
@@ -236,7 +236,7 @@ impl Pipeline {
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::TextureView(
- &texture_atlas.view(),
+ texture_atlas.view(),
),
}],
});
@@ -264,7 +264,7 @@ impl Pipeline {
#[cfg(feature = "image_rs")]
pub fn dimensions(&self, handle: &image::Handle) -> (u32, u32) {
let mut cache = self.raster_cache.borrow_mut();
- let memory = cache.load(&handle);
+ let memory = cache.load(handle);
memory.dimensions()
}
@@ -272,7 +272,7 @@ impl Pipeline {
#[cfg(feature = "svg")]
pub fn viewport_dimensions(&self, handle: &svg::Handle) -> (u32, u32) {
let mut cache = self.vector_cache.borrow_mut();
- let svg = cache.load(&handle);
+ let svg = cache.load(handle);
svg.viewport_dimensions()
}
@@ -358,7 +358,7 @@ impl Pipeline {
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::TextureView(
- &self.texture_atlas.view(),
+ self.texture_atlas.view(),
),
}],
});
diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs
index c1347e55..a5bfd9c0 100644
--- a/wgpu/src/image/atlas.rs
+++ b/wgpu/src/image/atlas.rs
@@ -118,7 +118,7 @@ impl Atlas {
height,
padding,
0,
- &allocation,
+ allocation,
encoder,
);
}
diff --git a/wgpu/src/image/atlas/layer.rs b/wgpu/src/image/atlas/layer.rs
index b1084ed9..cf089601 100644
--- a/wgpu/src/image/atlas/layer.rs
+++ b/wgpu/src/image/atlas/layer.rs
@@ -9,9 +9,6 @@ pub enum Layer {
impl Layer {
pub fn is_empty(&self) -> bool {
- match self {
- Layer::Empty => true,
- _ => false,
- }
+ matches!(self, Layer::Empty)
}
}
diff --git a/wgpu/src/image/raster.rs b/wgpu/src/image/raster.rs
index ec5e911f..bd6c1f45 100644
--- a/wgpu/src/image/raster.rs
+++ b/wgpu/src/image/raster.rs
@@ -59,7 +59,7 @@ impl Cache {
}
}
image::Data::Bytes(bytes) => {
- if let Ok(image) = image_rs::load_from_memory(&bytes) {
+ if let Ok(image) = image_rs::load_from_memory(bytes) {
let operation =
Operation::from_exif(&mut std::io::Cursor::new(bytes))
.ok()
diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs
index 4c830913..b08a0aa2 100644
--- a/wgpu/src/image/vector.rs
+++ b/wgpu/src/image/vector.rs
@@ -60,7 +60,7 @@ impl Cache {
}
svg::Data::Bytes(bytes) => {
match usvg::Tree::from_data(
- &bytes,
+ bytes,
&usvg::Options::default().to_ref(),
) {
Ok(tree) => Svg::Loaded(tree),
@@ -112,7 +112,7 @@ impl Cache {
// It would be cool to be able to smooth resize the `svg` example.
let mut img = tiny_skia::Pixmap::new(width, height)?;
- let _ = resvg::render(
+ resvg::render(
tree,
if width > height {
usvg::FitTo::Width(width)
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs
index 45f1f2de..e17b84c1 100644
--- a/wgpu/src/text.rs
+++ b/wgpu/src/text.rs
@@ -188,7 +188,8 @@ impl Pipeline {
}
b_count += utf8_len;
}
- return byte_index;
+
+ byte_index
};
if !nearest_only {
diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs
index 40e2f855..fd06dddf 100644
--- a/wgpu/src/triangle.rs
+++ b/wgpu/src/triangle.rs
@@ -173,9 +173,7 @@ impl Pipeline {
},
depth_stencil: None,
multisample: wgpu::MultisampleState {
- count: u32::from(
- antialiasing.map(|a| a.sample_count()).unwrap_or(1),
- ),
+ count: antialiasing.map(|a| a.sample_count()).unwrap_or(1),
mask: !0,
alpha_to_coverage_enabled: false,
},
@@ -272,47 +270,43 @@ impl Pipeline {
let vertices = bytemuck::cast_slice(&mesh.buffers.vertices);
let indices = bytemuck::cast_slice(&mesh.buffers.indices);
- match (
+ if let (Some(vertices_size), Some(indices_size)) = (
wgpu::BufferSize::new(vertices.len() as u64),
wgpu::BufferSize::new(indices.len() as u64),
) {
- (Some(vertices_size), Some(indices_size)) => {
- {
- let mut vertex_buffer = staging_belt.write_buffer(
- encoder,
- &self.vertex_buffer.raw,
- (std::mem::size_of::<Vertex2D>() * last_vertex)
- as u64,
- vertices_size,
- device,
- );
-
- vertex_buffer.copy_from_slice(vertices);
- }
-
- {
- let mut index_buffer = staging_belt.write_buffer(
- encoder,
- &self.index_buffer.raw,
- (std::mem::size_of::<u32>() * last_index) as u64,
- indices_size,
- device,
- );
-
- index_buffer.copy_from_slice(indices);
- }
-
- uniforms.push(transform);
- offsets.push((
- last_vertex as u64,
- last_index as u64,
- mesh.buffers.indices.len(),
- ));
-
- last_vertex += mesh.buffers.vertices.len();
- last_index += mesh.buffers.indices.len();
+ {
+ let mut vertex_buffer = staging_belt.write_buffer(
+ encoder,
+ &self.vertex_buffer.raw,
+ (std::mem::size_of::<Vertex2D>() * last_vertex) as u64,
+ vertices_size,
+ device,
+ );
+
+ vertex_buffer.copy_from_slice(vertices);
+ }
+
+ {
+ let mut index_buffer = staging_belt.write_buffer(
+ encoder,
+ &self.index_buffer.raw,
+ (std::mem::size_of::<u32>() * last_index) as u64,
+ indices_size,
+ device,
+ );
+
+ index_buffer.copy_from_slice(indices);
}
- _ => {}
+
+ uniforms.push(transform);
+ offsets.push((
+ last_vertex as u64,
+ last_index as u64,
+ mesh.buffers.indices.len(),
+ ));
+
+ last_vertex += mesh.buffers.vertices.len();
+ last_index += mesh.buffers.indices.len();
}
}
diff --git a/wgpu/src/triangle/msaa.rs b/wgpu/src/triangle/msaa.rs
index 7edeeb94..a3016ff8 100644
--- a/wgpu/src/triangle/msaa.rs
+++ b/wgpu/src/triangle/msaa.rs
@@ -134,7 +134,7 @@ impl Blit {
match &mut self.targets {
None => {
self.targets = Some(Targets::new(
- &device,
+ device,
self.format,
&self.texture_layout,
self.sample_count,
@@ -145,7 +145,7 @@ impl Blit {
Some(targets) => {
if targets.width != width || targets.height != height {
self.targets = Some(Targets::new(
- &device,
+ device,
self.format,
&self.texture_layout,
self.sample_count,
diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs
index fa1f441a..a36d2a87 100644
--- a/wgpu/src/window/compositor.rs
+++ b/wgpu/src/window/compositor.rs
@@ -225,7 +225,7 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
renderer.with_primitives(|backend, primitives| {
backend.present(
- &mut self.device,
+ &self.device,
&mut self.staging_belt,
&mut encoder,
view,
diff --git a/winit/src/application.rs b/winit/src/application.rs
index 9c7dd74e..99402cf5 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -647,7 +647,7 @@ mod platform {
{
use winit::platform::run_return::EventLoopExtRunReturn;
- let _ = event_loop.run_return(event_handler);
+ event_loop.run_return(event_handler);
Ok(())
}
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index 8e6c0b37..74f6f7a0 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -485,10 +485,10 @@ pub fn key_code(
// As defined in: http://www.unicode.org/faq/private_use.html
pub(crate) fn is_private_use_character(c: char) -> bool {
- match c {
+ matches!(
+ c,
'\u{E000}'..='\u{F8FF}'
| '\u{F0000}'..='\u{FFFFD}'
- | '\u{100000}'..='\u{10FFFD}' => true,
- _ => false,
- }
+ | '\u{100000}'..='\u{10FFFD}'
+ )
}
diff --git a/winit/src/system.rs b/winit/src/system.rs
index 0ed61dc9..0303707e 100644
--- a/winit/src/system.rs
+++ b/winit/src/system.rs
@@ -24,7 +24,7 @@ pub(crate) fn information(
let memory_used = sysinfo::get_current_pid()
.and_then(|pid| system.process(pid).ok_or("Process not found"))
- .and_then(|process| Ok(process.memory()))
+ .map(|process| process.memory())
.ok();
Information {