From 56b6d6571ca4292a3c2293ec05d537e12da972e5 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 7 Dec 2023 18:44:18 -0500 Subject: [PATCH] cleanup: formatting and clippy --- examples/integration/src/controls.rs | 2 +- examples/integration/src/main.rs | 4 ++-- examples/sctk_todos/src/main.rs | 4 ---- runtime/src/program/state.rs | 2 +- src/application.rs | 1 - src/wayland/mod.rs | 4 ++-- src/wayland/sandbox.rs | 4 ---- tiny_skia/src/window/compositor.rs | 8 ++++---- winit/src/application.rs | 10 ++-------- winit/src/conversion.rs | 3 --- winit/src/multi_window.rs | 8 ++------ 11 files changed, 14 insertions(+), 36 deletions(-) diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs index 8bf887faed..c81db9e72f 100644 --- a/examples/integration/src/controls.rs +++ b/examples/integration/src/controls.rs @@ -46,7 +46,7 @@ impl Program for Controls { Command::none() } - fn view(&self, _: Id) -> Element> { + fn view(&self) -> Element> { let background_color = self.background_color; let text = &self.text; diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 7dfedbe9e3..03be223cb9 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -154,7 +154,7 @@ pub fn main() -> Result<(), Box> { ); let mut state = program::State::new( - Id(0), + Id::MAIN, controls, viewport.logical_size(), &mut renderer, @@ -199,7 +199,7 @@ pub fn main() -> Result<(), Box> { if !state.is_queue_empty() { // We update iced let _ = state.update( - Id(0), + Id::MAIN, viewport.logical_size(), cursor_position .map(|p| { diff --git a/examples/sctk_todos/src/main.rs b/examples/sctk_todos/src/main.rs index f6a6cf1600..ce986c85b6 100644 --- a/examples/sctk_todos/src/main.rs +++ b/examples/sctk_todos/src/main.rs @@ -1,11 +1,8 @@ use env_logger::Env; use iced::alignment::{self, Alignment}; use iced::event::{self, listen_raw, Event}; -use iced::subscription; use iced::theme::{self, Theme}; -use iced::wayland::actions::data_device::ActionInner; use iced::wayland::actions::window::SctkWindowSettings; -use iced::wayland::data_device::action as data_device_action; use iced::wayland::InitialSurface; use iced::widget::{ self, button, checkbox, column, container, row, scrollable, text, @@ -20,7 +17,6 @@ use iced_core::{id, keyboard}; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use std::fmt::Debug; -use std::sync::Arc; static INPUT_ID: Lazy = Lazy::new(Id::unique); diff --git a/runtime/src/program/state.rs b/runtime/src/program/state.rs index 4b9c36aeb1..0db55d086f 100644 --- a/runtime/src/program/state.rs +++ b/runtime/src/program/state.rs @@ -275,7 +275,7 @@ where } fn build_user_interface<'a, P: Program>( - id: crate::window::Id, + _id: crate::window::Id, program: &'a mut P, cache: user_interface::Cache, renderer: &mut P::Renderer, diff --git a/src/application.rs b/src/application.rs index eb91ab4a63..005c13c541 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,5 +1,4 @@ //! Build interactive cross-platform applications. -use iced_core::window::Id; use crate::{Command, Element, Executor, Settings, Subscription}; diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 541d1562f4..72133b9184 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -60,7 +60,7 @@ pub trait Application: Sized { /// Returns the current [`Theme`] of the [`Application`]. /// /// [`Theme`]: Self::Theme - fn theme(&self, id: Id) -> Self::Theme { + fn theme(&self, _id: Id) -> Self::Theme { Self::Theme::default() } @@ -98,7 +98,7 @@ pub trait Application: Sized { /// while a scale factor of `0.5` will shrink them to half their size. /// /// By default, it returns `1.0`. - fn scale_factor(&self, id: Id) -> f64 { + fn scale_factor(&self, _id: Id) -> f64 { 1.0 } diff --git a/src/wayland/sandbox.rs b/src/wayland/sandbox.rs index 4205f1a1c2..bffafb7ae7 100644 --- a/src/wayland/sandbox.rs +++ b/src/wayland/sandbox.rs @@ -81,10 +81,6 @@ use crate::{ /// fn view(&self, _: Id) -> Element { /// "Hello, world!".into() /// } -/// -/// fn close_requested(&self, _: Id) -> Self::Message { -/// unimplemented!() -/// } /// } /// ``` pub trait Sandbox { diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 91e621f481..bf73cfcdce 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -183,10 +183,10 @@ pub fn present>( surface .window .resize( - NonZeroU32::new(physical_size.width as u32) - .ok_or_else(|| compositor::SurfaceError::InvalidDimensions)?, - NonZeroU32::new(physical_size.height as u32) - .ok_or_else(|| compositor::SurfaceError::InvalidDimensions)?, + NonZeroU32::new(physical_size.width) + .ok_or(compositor::SurfaceError::InvalidDimensions)?, + NonZeroU32::new(physical_size.height) + .ok_or(compositor::SurfaceError::InvalidDimensions)?, ) .map_err(|_| compositor::SurfaceError::Resize)?; if let Ok(mut b) = surface.window.buffer_mut() { diff --git a/winit/src/application.rs b/winit/src/application.rs index c887bd9a86..9cd992f427 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -1,7 +1,5 @@ //! Create interactive, native cross-platform applications. mod drag_resize; -#[cfg(feature = "trace")] -mod profiler; mod state; #[cfg(feature = "a11y")] @@ -918,14 +916,10 @@ pub fn run_command( for action in command.actions() { match action { command::Action::Future(future) => { - runtime.spawn(Box::pin( - future.map(|e| UserEventWrapper::Message(e)), - )); + runtime.spawn(Box::pin(future.map(UserEventWrapper::Message))); } command::Action::Stream(stream) => { - runtime.run(Box::pin( - stream.map(|e| UserEventWrapper::Message(e)), - )); + runtime.run(Box::pin(stream.map(UserEventWrapper::Message))); } command::Action::Clipboard(action) => match action { clipboard::Action::Read(tag) => { diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 252783fc5e..c10204cece 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -160,9 +160,6 @@ pub fn window_event( WindowEvent::CloseRequested => { Some(Event::Window(id, window::Event::CloseRequested)) } - WindowEvent::CloseRequested => { - Some(Event::Window(id, window::Event::CloseRequested)) - } WindowEvent::CursorMoved { position, .. } => { let position = position.to_logical::(scale_factor); diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index 8cf8357c88..a10161e656 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -965,14 +965,10 @@ fn run_command( for action in command.actions() { match action { command::Action::Future(future) => { - runtime.spawn(Box::pin( - future.map(|e| UserEventWrapper::Message(e)), - )); + runtime.spawn(Box::pin(future.map(UserEventWrapper::Message))); } command::Action::Stream(stream) => { - runtime.run(Box::pin( - stream.map(|e| UserEventWrapper::Message(e)), - )); + runtime.run(Box::pin(stream.map(UserEventWrapper::Message))); } command::Action::Clipboard(action) => match action { clipboard::Action::Read(tag) => {