Skip to content

Commit 79e74f5

Browse files
committed
clippy
1 parent 909bb2b commit 79e74f5

28 files changed

Lines changed: 55 additions & 71 deletions

File tree

accessibility/src/id.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ impl From<Id> for u64 {
124124
}
125125
}
126126

127-
impl ToString for Id {
128-
fn to_string(&self) -> String {
127+
impl std::fmt::Display for Id {
128+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
129129
match &self.0 {
130-
Internal::Unique(_) => "Undefined".to_string(),
131-
Internal::Custom(_, id) => id.to_string(),
132-
Internal::Set(_) => "Set".to_string(),
130+
Internal::Unique(_) => write!(f, "Undefined"),
131+
Internal::Custom(_, id) => write!(f, "{}", id.to_string()),
132+
Internal::Set(_) => write!(f, "Set"),
133133
}
134134
}
135135
}

core/src/clipboard.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub trait Clipboard {
2020
/// Reads the current content of the [`Clipboard`] as text.
2121
fn read_data(
2222
&self,
23-
kind: Kind,
23+
_kind: Kind,
2424
_mimes: Vec<String>,
2525
) -> Option<(Vec<u8>, String)> {
2626
None
@@ -29,7 +29,7 @@ pub trait Clipboard {
2929
/// Writes the given contents to the [`Clipboard`].
3030
fn write_data(
3131
&mut self,
32-
kind: Kind,
32+
_kind: Kind,
3333
_contents: ClipboardStoreData<
3434
Box<dyn Send + Sync + 'static + mime::AsMimeTypes>,
3535
>,
@@ -70,7 +70,7 @@ pub trait Clipboard {
7070
}
7171

7272
/// Request window size
73-
fn request_logical_window_size(&self, width: f32, height: f32) {}
73+
fn request_logical_window_size(&self, _width: f32, _height: f32) {}
7474
}
7575

7676
/// The kind of [`Clipboard`].
@@ -141,10 +141,7 @@ pub fn peek_dnd<T: AllowedMimeTypes>(
141141
clipboard: &mut dyn Clipboard,
142142
mime: Option<String>,
143143
) -> Option<T> {
144-
let Some(mime) = mime.or_else(|| T::allowed().first().cloned().into())
145-
else {
146-
return None;
147-
};
144+
let mime = mime.or_else(|| T::allowed().first().cloned())?;
148145
clipboard
149146
.peek_dnd(mime)
150147
.and_then(|data| T::try_from(data).ok())
@@ -160,7 +157,7 @@ pub enum DndSource {
160157
}
161158

162159
/// A list of DnD destination rectangles.
163-
#[derive(Debug, Clone)]
160+
#[derive(Debug, Clone, Default)]
164161
pub struct DndDestinationRectangles {
165162
/// The rectangle of the DnD destination.
166163
rectangles: Vec<DndDestinationRectangle>,
@@ -169,9 +166,7 @@ pub struct DndDestinationRectangles {
169166
impl DndDestinationRectangles {
170167
/// Creates a new [`DndDestinationRectangles`].
171168
pub fn new() -> Self {
172-
Self {
173-
rectangles: Vec::new(),
174-
}
169+
Self::default()
175170
}
176171

177172
/// Creates a new [`DndDestinationRectangles`] with the given capacity.

core/src/element.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ where
311311
}
312312

313313
fn diff(&mut self, tree: &mut Tree) {
314-
self.widget.diff(tree)
314+
self.widget.diff(tree);
315315
}
316316

317317
fn size(&self) -> Size<Length> {

core/src/id.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ impl From<Id> for NonZeroU128 {
6060
}
6161
}
6262

63-
impl ToString for Id {
64-
fn to_string(&self) -> String {
63+
impl std::fmt::Display for Id {
64+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6565
match &self.0 {
66-
Internal::Unique(_) => "Undefined".to_string(),
67-
Internal::Custom(_, id) => id.to_string(),
68-
Internal::Set(_) => "Set".to_string(),
66+
Internal::Unique(_) => write!(f, "Undefined"),
67+
Internal::Custom(_, id) => write!(f, "{}", id.to_string()),
68+
Internal::Set(_) => write!(f, "Set"),
6969
}
7070
}
7171
}

core/src/overlay/group.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::mouse;
44
use crate::overlay;
55
use crate::renderer;
66
use crate::widget;
7-
use crate::widget::Operation;
87
use crate::{Clipboard, Event, Layout, Overlay, Point, Rectangle, Shell, Size};
98

109
/// An [`Overlay`] container that displays multiple overlay [`overlay::Element`]

core/src/renderer/null.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::alignment;
2-
use crate::image::{self, Image};
2+
use crate::image;
33
use crate::renderer::{self, Renderer};
44
use crate::svg;
55
use crate::text::{self, Text};

core/src/theme.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ impl Theme {
160160
}
161161
}
162162

163+
#[allow(clippy::derivable_impls)]
163164
impl Default for Theme {
164165
fn default() -> Self {
165166
#[cfg(feature = "auto-detect-theme")]

core/src/widget/text.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ use crate::{
3232
Widget,
3333
};
3434

35-
use std::borrow::Cow;
36-
3735
pub use text::{LineHeight, Shaping, Wrapping};
3836

3937
/// A bunch of text.
@@ -313,7 +311,7 @@ where
313311
}
314312

315313
fn set_id(&mut self, id: crate::widget::Id) {
316-
self.id = id
314+
self.id = id;
317315
}
318316
}
319317

core/src/widget/tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ impl Tree {
269269
new_children.iter().map(|c| c.borrow().id()).collect(),
270270
|tree, widget| {
271271
let borrowed: &mut dyn Widget<_, _, _> = widget.borrow_mut();
272-
tree.diff(borrowed)
272+
tree.diff(borrowed);
273273
},
274274
|widget| {
275275
let borrowed: &dyn Widget<_, _, _> = widget.borrow();
276276
Self::new(borrowed)
277277
},
278-
)
278+
);
279279
}
280280

281281
/// Reconciles the children of the tree with the provided list of widgets using custom

graphics/src/image.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ pub use ::image as image_rs;
44

55
use crate::core::image;
66
use crate::core::svg;
7-
use crate::core::Color;
8-
use crate::core::Radians;
97
use crate::core::Rectangle;
108

119
/// A raster or vector image.

0 commit comments

Comments
 (0)