diff --git a/src/event_loop.rs b/src/event_loop.rs index a10ba368..1f00f7d7 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -331,6 +331,7 @@ impl EventLoopWindowTarget { /// Returns the list of all the monitors available on the system. #[inline] pub fn available_monitors(&self) -> impl Iterator { + #[allow(clippy::useless_conversion)] // false positive on some platforms self.p .available_monitors() .into_iter() diff --git a/src/platform/ios.rs b/src/platform/ios.rs index 3fa92c79..6b153784 100644 --- a/src/platform/ios.rs +++ b/src/platform/ios.rs @@ -253,9 +253,10 @@ impl MonitorHandleExtIOS for MonitorHandle { } /// Valid orientations for a particular [`Window`]. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Default)] pub enum ValidOrientations { /// Excludes `PortraitUpsideDown` on iphone + #[default] LandscapeAndPortrait, Landscape, @@ -264,13 +265,6 @@ pub enum ValidOrientations { Portrait, } -impl Default for ValidOrientations { - #[inline] - fn default() -> ValidOrientations { - ValidOrientations::LandscapeAndPortrait - } -} - /// The device [idiom]. /// /// [idiom]: https://developer.apple.com/documentation/uikit/uidevice/1620037-userinterfaceidiom?language=objc diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 586f4320..0b6ebf11 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -122,22 +122,19 @@ impl WindowExtMacOS for Window { } /// Corresponds to `NSApplicationActivationPolicy`. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)] pub enum ActivationPolicy { /// Corresponds to `NSApplicationActivationPolicyRegular`. + #[default] Regular, + /// Corresponds to `NSApplicationActivationPolicyAccessory`. Accessory, + /// Corresponds to `NSApplicationActivationPolicyProhibited`. Prohibited, } -impl Default for ActivationPolicy { - fn default() -> Self { - ActivationPolicy::Regular - } -} - /// Additional methods on [`WindowBuilder`] that are specific to MacOS. /// /// **Note:** Properties dealing with the titlebar will be overwritten by the [`WindowBuilder::with_decorations`] method: @@ -348,7 +345,7 @@ impl EventLoopWindowTargetExtMacOS for EventLoopWindowTarget { /// Option as alt behavior. /// /// The default is `None`. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum OptionAsAlt { /// The left `Option` key is treated as `Alt`. @@ -361,11 +358,6 @@ pub enum OptionAsAlt { Both, /// No special handling is applied for `Option` key. + #[default] None, } - -impl Default for OptionAsAlt { - fn default() -> Self { - OptionAsAlt::None - } -} diff --git a/src/platform_impl/linux/x11/util/hint.rs b/src/platform_impl/linux/x11/util/hint.rs index bde63c23..96157e70 100644 --- a/src/platform_impl/linux/x11/util/hint.rs +++ b/src/platform_impl/linux/x11/util/hint.rs @@ -23,7 +23,7 @@ impl From for StateOperation { /// X window type. Maps directly to /// [`_NET_WM_WINDOW_TYPE`](https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html). -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum WindowType { /// A desktop feature. This can include a single window containing desktop icons with the same dimensions as the @@ -61,15 +61,10 @@ pub enum WindowType { /// This property is typically used on override-redirect windows. Dnd, /// This is a normal, top-level window. + #[default] Normal, } -impl Default for WindowType { - fn default() -> Self { - WindowType::Normal - } -} - impl WindowType { pub(crate) fn as_atom(&self, xconn: &Arc) -> ffi::Atom { use self::WindowType::*; diff --git a/src/window.rs b/src/window.rs index 46bb3b8e..50d8cd24 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1299,6 +1299,7 @@ impl Window { /// [`EventLoopWindowTarget::available_monitors`]: crate::event_loop::EventLoopWindowTarget::available_monitors #[inline] pub fn available_monitors(&self) -> impl Iterator { + #[allow(clippy::useless_conversion)] // false positive on some platforms self.window .available_monitors() .into_iter() @@ -1388,10 +1389,11 @@ pub enum CursorGrabMode { } /// Describes the appearance of the mouse cursor. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum CursorIcon { /// The platform-dependent default cursor. + #[default] Default, /// A simple crosshair. Crosshair, @@ -1446,12 +1448,6 @@ pub enum CursorIcon { RowResize, } -impl Default for CursorIcon { - fn default() -> Self { - CursorIcon::Default - } -} - /// Defines the orientation that a window resize will be performed. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum ResizeDirection { @@ -1507,26 +1503,22 @@ pub enum Theme { /// /// [`Critical`]: Self::Critical /// [`Informational`]: Self::Informational -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] pub enum UserAttentionType { /// ## Platform-specific /// /// - **macOS:** Bounces the dock icon until the application is in focus. /// - **Windows:** Flashes both the window and the taskbar button until the application is in focus. Critical, + /// ## Platform-specific /// /// - **macOS:** Bounces the dock icon once. /// - **Windows:** Flashes the taskbar button until the application is in focus. + #[default] Informational, } -impl Default for UserAttentionType { - fn default() -> Self { - UserAttentionType::Informational - } -} - bitflags! { pub struct WindowButtons: u32 { const CLOSE = 1 << 0; @@ -1543,24 +1535,21 @@ bitflags! { /// ## Platform-specific /// /// - **iOS / Android / Web / Wayland:** Unsupported. -#[derive(Debug, PartialEq, Eq, Clone, Copy)] +#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)] pub enum WindowLevel { /// The window will always be below normal windows. /// /// This is useful for a widget-based app. AlwaysOnBottom, + /// The default. + #[default] Normal, + /// The window will always be on top of normal windows. AlwaysOnTop, } -impl Default for WindowLevel { - fn default() -> Self { - Self::Normal - } -} - /// Generic IME purposes for use in [`Window::set_ime_purpose`]. /// /// The purpose may improve UX by optimizing the IME for the specific use case,