clippy
This commit is contained in:
parent
df4b94edf2
commit
2dd6137459
19 changed files with 42 additions and 53 deletions
|
|
@ -137,12 +137,12 @@ impl From<Id> for u64 {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToString for Id {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Id {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match &self.0 {
|
||||
Internal::Unique(_) => "Undefined".to_string(),
|
||||
Internal::Custom(_, id) => id.to_string(),
|
||||
Internal::Set(_) => "Set".to_string(),
|
||||
Internal::Unique(_) => write!(f, "Undefined"),
|
||||
Internal::Custom(_, id) => write!(f, "{}", id.to_string()),
|
||||
Internal::Set(_) => write!(f, "Set"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ pub trait Clipboard {
|
|||
/// Reads the current content of the [`Clipboard`] as text.
|
||||
fn read_data(
|
||||
&self,
|
||||
kind: Kind,
|
||||
_kind: Kind,
|
||||
_mimes: Vec<String>,
|
||||
) -> Option<(Vec<u8>, String)> {
|
||||
None
|
||||
|
|
@ -78,7 +78,7 @@ pub trait Clipboard {
|
|||
/// Writes the given contents to the [`Clipboard`].
|
||||
fn write_data(
|
||||
&mut self,
|
||||
kind: Kind,
|
||||
_kind: Kind,
|
||||
_contents: ClipboardStoreData<
|
||||
Box<dyn Send + Sync + 'static + mime::AsMimeTypes>,
|
||||
>,
|
||||
|
|
@ -119,7 +119,7 @@ pub trait Clipboard {
|
|||
}
|
||||
|
||||
/// Request window size
|
||||
fn request_logical_window_size(&self, width: f32, height: f32) {}
|
||||
fn request_logical_window_size(&self, _width: f32, _height: f32) {}
|
||||
}
|
||||
|
||||
/// The kind of [`Clipboard`].
|
||||
|
|
@ -187,10 +187,7 @@ pub fn peek_dnd<T: AllowedMimeTypes>(
|
|||
clipboard: &mut dyn Clipboard,
|
||||
mime: Option<String>,
|
||||
) -> Option<T> {
|
||||
let Some(mime) = mime.or_else(|| T::allowed().first().cloned().into())
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let mime = mime.or_else(|| T::allowed().first().cloned())?;
|
||||
clipboard
|
||||
.peek_dnd(mime)
|
||||
.and_then(|data| T::try_from(data).ok())
|
||||
|
|
@ -206,7 +203,7 @@ pub enum DndSource {
|
|||
}
|
||||
|
||||
/// A list of DnD destination rectangles.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct DndDestinationRectangles {
|
||||
/// The rectangle of the DnD destination.
|
||||
rectangles: Vec<DndDestinationRectangle>,
|
||||
|
|
@ -215,9 +212,7 @@ pub struct DndDestinationRectangles {
|
|||
impl DndDestinationRectangles {
|
||||
/// Creates a new [`DndDestinationRectangles`].
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
rectangles: Vec::new(),
|
||||
}
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Creates a new [`DndDestinationRectangles`] with the given capacity.
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ where
|
|||
}
|
||||
|
||||
fn diff(&mut self, tree: &mut Tree) {
|
||||
self.widget.diff(tree)
|
||||
self.widget.diff(tree);
|
||||
}
|
||||
|
||||
fn size(&self) -> Size<Length> {
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ impl From<Id> for NonZeroU128 {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToString for Id {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Id {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match &self.0 {
|
||||
Internal::Unique(_) => "Undefined".to_string(),
|
||||
Internal::Custom(_, id) => id.to_string(),
|
||||
Internal::Set(_) => "Set".to_string(),
|
||||
Internal::Unique(_) => write!(f, "Undefined"),
|
||||
Internal::Custom(_, id) => write!(f, "{}", id.to_string()),
|
||||
Internal::Set(_) => write!(f, "Set"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use crate::mouse;
|
|||
use crate::overlay;
|
||||
use crate::renderer;
|
||||
use crate::widget;
|
||||
use crate::widget::Operation;
|
||||
use crate::{Clipboard, Event, Layout, Overlay, Point, Rectangle, Shell, Size};
|
||||
|
||||
/// An [`Overlay`] container that displays multiple overlay [`overlay::Element`]
|
||||
|
|
|
|||
|
|
@ -269,13 +269,13 @@ impl Tree {
|
|||
new_children.iter().map(|c| c.borrow().id()).collect(),
|
||||
|tree, widget| {
|
||||
let borrowed: &mut dyn Widget<_, _, _> = widget.borrow_mut();
|
||||
tree.diff(borrowed)
|
||||
tree.diff(borrowed);
|
||||
},
|
||||
|widget| {
|
||||
let borrowed: &dyn Widget<_, _, _> = widget.borrow();
|
||||
Self::new(borrowed)
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/// Reconciles the children of the tree with the provided list of widgets using custom
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ pub fn peek_dnd<T: AllowedMimeTypes>() -> Task<Option<T>> {
|
|||
task::oneshot(|tx| {
|
||||
Action::Dnd(DndAction::PeekDnd(
|
||||
T::allowed()
|
||||
.get(0)
|
||||
.map_or_else(|| String::new(), |s| s.to_string()),
|
||||
.first()
|
||||
.map_or_else(String::new, std::string::ToString::to_string),
|
||||
tx,
|
||||
))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ pub type Element<
|
|||
/// The result of running an iced program.
|
||||
pub type Result = std::result::Result<(), Error>;
|
||||
|
||||
#[cfg(any(feature = "winit"))]
|
||||
#[cfg(feature = "winit")]
|
||||
/// Runs a basic iced application with default [`Settings`] given its title,
|
||||
/// update, and view logic.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ impl Engine {
|
|||
let center = physical_bounds.center();
|
||||
let radians = f32::from(svg.rotation);
|
||||
|
||||
let transform = Transform::default().post_rotate_at(
|
||||
let transform = tiny_skia::Transform::default().post_rotate_at(
|
||||
radians.to_degrees(),
|
||||
center.x,
|
||||
center.y,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::Primitive;
|
||||
use crate::core::renderer::Quad;
|
||||
use crate::core::{
|
||||
self, Background, Color, Point, Radians, Rectangle, Svg, Transformation,
|
||||
self, Background, Color, Point, Rectangle, Svg, Transformation,
|
||||
};
|
||||
use crate::graphics::damage;
|
||||
use crate::graphics::layer;
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ where
|
|||
}
|
||||
|
||||
fn diff(&mut self, tree: &mut Tree) {
|
||||
tree.diff_children(std::slice::from_mut(&mut self.content))
|
||||
tree.diff_children(std::slice::from_mut(&mut self.content));
|
||||
}
|
||||
|
||||
fn size(&self) -> Size<Length> {
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ where
|
|||
size,
|
||||
line_height,
|
||||
shaping,
|
||||
wrap,
|
||||
wrap: _,
|
||||
} = &self.icon;
|
||||
let size = size.unwrap_or(Pixels(bounds.height * 0.7));
|
||||
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ pub fn visible_bounds(id: Id) -> Task<Option<Rectangle>> {
|
|||
}
|
||||
|
||||
task::widget(VisibleBounds {
|
||||
target: id.into(),
|
||||
target: id,
|
||||
depth: 0,
|
||||
scrollables: Vec::new(),
|
||||
bounds: None,
|
||||
|
|
|
|||
|
|
@ -164,11 +164,11 @@ impl Default for State {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
is_hovered: Default::default(),
|
||||
drag_initiated: Default::default(),
|
||||
drag_initiated: None,
|
||||
is_out_of_bounds: true,
|
||||
last_click: Default::default(),
|
||||
last_click: None,
|
||||
cursor_position: None,
|
||||
bounds: Default::default(),
|
||||
bounds: Rectangle::default(),
|
||||
previous_click: None,
|
||||
}
|
||||
}
|
||||
|
|
@ -351,7 +351,7 @@ where
|
|||
renderer: &Renderer,
|
||||
dnd_rectangles: &mut crate::core::clipboard::DndDestinationRectangles,
|
||||
) {
|
||||
if let Some(state) = state.children.iter().next() {
|
||||
if let Some(state) = state.children.first() {
|
||||
self.content.as_widget().drag_destinations(
|
||||
state,
|
||||
layout,
|
||||
|
|
@ -420,20 +420,19 @@ fn update<Message: Clone, Theme, Renderer>(
|
|||
}
|
||||
|
||||
if !cursor.is_over(layout.bounds()) {
|
||||
if !state.is_out_of_bounds {
|
||||
if widget
|
||||
if !state.is_out_of_bounds
|
||||
&& widget
|
||||
.on_enter
|
||||
.as_ref()
|
||||
.or(widget.on_exit.as_ref())
|
||||
.is_some()
|
||||
{
|
||||
if let Event::Mouse(mouse::Event::CursorMoved { .. }) = event {
|
||||
state.is_out_of_bounds = true;
|
||||
if let Some(message) = widget.on_exit.as_ref() {
|
||||
shell.publish(message.clone());
|
||||
}
|
||||
return;
|
||||
{
|
||||
if let Event::Mouse(mouse::Event::CursorMoved { .. }) = event {
|
||||
state.is_out_of_bounds = true;
|
||||
if let Some(message) = widget.on_exit.as_ref() {
|
||||
shell.publish(message.clone());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
use iced_renderer::core::widget::Operation;
|
||||
|
||||
use crate::container;
|
||||
use crate::core::layout;
|
||||
use crate::core::mouse;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
use iced_renderer::core::widget::Operation;
|
||||
|
||||
use crate::container;
|
||||
use crate::core::layout;
|
||||
use crate::core::mouse;
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ where
|
|||
}
|
||||
|
||||
fn diff(&mut self, tree: &mut Tree) {
|
||||
tree.diff_children(&mut self.children)
|
||||
tree.diff_children(&mut self.children);
|
||||
}
|
||||
|
||||
fn size(&self) -> Size<Length> {
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ where
|
|||
}
|
||||
|
||||
fn diff(&mut self, tree: &mut Tree) {
|
||||
tree.diff_children(std::slice::from_mut(&mut self.content))
|
||||
tree.diff_children(std::slice::from_mut(&mut self.content));
|
||||
}
|
||||
|
||||
fn size(&self) -> Size<Length> {
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ where
|
|||
tree.diff_children(&mut [
|
||||
self.content.as_widget_mut(),
|
||||
self.tooltip.as_widget_mut(),
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
fn layout(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue