Fix 1.68 clippy warnings

This commit is contained in:
Emil Ernerfeldt 2023-03-12 18:02:49 +01:00 committed by GitHub
parent b18295a1ce
commit 3217eaa416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 50 deletions

View file

@ -331,6 +331,7 @@ impl<T> EventLoopWindowTarget<T> {
/// Returns the list of all the monitors available on the system. /// Returns the list of all the monitors available on the system.
#[inline] #[inline]
pub fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle> { pub fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle> {
#[allow(clippy::useless_conversion)] // false positive on some platforms
self.p self.p
.available_monitors() .available_monitors()
.into_iter() .into_iter()

View file

@ -253,9 +253,10 @@ impl MonitorHandleExtIOS for MonitorHandle {
} }
/// Valid orientations for a particular [`Window`]. /// Valid orientations for a particular [`Window`].
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug, Default)]
pub enum ValidOrientations { pub enum ValidOrientations {
/// Excludes `PortraitUpsideDown` on iphone /// Excludes `PortraitUpsideDown` on iphone
#[default]
LandscapeAndPortrait, LandscapeAndPortrait,
Landscape, Landscape,
@ -264,13 +265,6 @@ pub enum ValidOrientations {
Portrait, Portrait,
} }
impl Default for ValidOrientations {
#[inline]
fn default() -> ValidOrientations {
ValidOrientations::LandscapeAndPortrait
}
}
/// The device [idiom]. /// The device [idiom].
/// ///
/// [idiom]: https://developer.apple.com/documentation/uikit/uidevice/1620037-userinterfaceidiom?language=objc /// [idiom]: https://developer.apple.com/documentation/uikit/uidevice/1620037-userinterfaceidiom?language=objc

View file

@ -122,22 +122,19 @@ impl WindowExtMacOS for Window {
} }
/// Corresponds to `NSApplicationActivationPolicy`. /// Corresponds to `NSApplicationActivationPolicy`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ActivationPolicy { pub enum ActivationPolicy {
/// Corresponds to `NSApplicationActivationPolicyRegular`. /// Corresponds to `NSApplicationActivationPolicyRegular`.
#[default]
Regular, Regular,
/// Corresponds to `NSApplicationActivationPolicyAccessory`. /// Corresponds to `NSApplicationActivationPolicyAccessory`.
Accessory, Accessory,
/// Corresponds to `NSApplicationActivationPolicyProhibited`. /// Corresponds to `NSApplicationActivationPolicyProhibited`.
Prohibited, Prohibited,
} }
impl Default for ActivationPolicy {
fn default() -> Self {
ActivationPolicy::Regular
}
}
/// Additional methods on [`WindowBuilder`] that are specific to MacOS. /// Additional methods on [`WindowBuilder`] that are specific to MacOS.
/// ///
/// **Note:** Properties dealing with the titlebar will be overwritten by the [`WindowBuilder::with_decorations`] method: /// **Note:** Properties dealing with the titlebar will be overwritten by the [`WindowBuilder::with_decorations`] method:
@ -348,7 +345,7 @@ impl<T> EventLoopWindowTargetExtMacOS for EventLoopWindowTarget<T> {
/// Option as alt behavior. /// Option as alt behavior.
/// ///
/// The default is `None`. /// The default is `None`.
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum OptionAsAlt { pub enum OptionAsAlt {
/// The left `Option` key is treated as `Alt`. /// The left `Option` key is treated as `Alt`.
@ -361,11 +358,6 @@ pub enum OptionAsAlt {
Both, Both,
/// No special handling is applied for `Option` key. /// No special handling is applied for `Option` key.
#[default]
None, None,
} }
impl Default for OptionAsAlt {
fn default() -> Self {
OptionAsAlt::None
}
}

View file

@ -23,7 +23,7 @@ impl From<bool> for StateOperation {
/// X window type. Maps directly to /// X window type. Maps directly to
/// [`_NET_WM_WINDOW_TYPE`](https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html). /// [`_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))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum WindowType { pub enum WindowType {
/// A desktop feature. This can include a single window containing desktop icons with the same dimensions as the /// 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. /// This property is typically used on override-redirect windows.
Dnd, Dnd,
/// This is a normal, top-level window. /// This is a normal, top-level window.
#[default]
Normal, Normal,
} }
impl Default for WindowType {
fn default() -> Self {
WindowType::Normal
}
}
impl WindowType { impl WindowType {
pub(crate) fn as_atom(&self, xconn: &Arc<XConnection>) -> ffi::Atom { pub(crate) fn as_atom(&self, xconn: &Arc<XConnection>) -> ffi::Atom {
use self::WindowType::*; use self::WindowType::*;

View file

@ -1299,6 +1299,7 @@ impl Window {
/// [`EventLoopWindowTarget::available_monitors`]: crate::event_loop::EventLoopWindowTarget::available_monitors /// [`EventLoopWindowTarget::available_monitors`]: crate::event_loop::EventLoopWindowTarget::available_monitors
#[inline] #[inline]
pub fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle> { pub fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle> {
#[allow(clippy::useless_conversion)] // false positive on some platforms
self.window self.window
.available_monitors() .available_monitors()
.into_iter() .into_iter()
@ -1388,10 +1389,11 @@ pub enum CursorGrabMode {
} }
/// Describes the appearance of the mouse cursor. /// 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))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum CursorIcon { pub enum CursorIcon {
/// The platform-dependent default cursor. /// The platform-dependent default cursor.
#[default]
Default, Default,
/// A simple crosshair. /// A simple crosshair.
Crosshair, Crosshair,
@ -1446,12 +1448,6 @@ pub enum CursorIcon {
RowResize, RowResize,
} }
impl Default for CursorIcon {
fn default() -> Self {
CursorIcon::Default
}
}
/// Defines the orientation that a window resize will be performed. /// Defines the orientation that a window resize will be performed.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum ResizeDirection { pub enum ResizeDirection {
@ -1507,26 +1503,22 @@ pub enum Theme {
/// ///
/// [`Critical`]: Self::Critical /// [`Critical`]: Self::Critical
/// [`Informational`]: Self::Informational /// [`Informational`]: Self::Informational
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum UserAttentionType { pub enum UserAttentionType {
/// ## Platform-specific /// ## Platform-specific
/// ///
/// - **macOS:** Bounces the dock icon until the application is in focus. /// - **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. /// - **Windows:** Flashes both the window and the taskbar button until the application is in focus.
Critical, Critical,
/// ## Platform-specific /// ## Platform-specific
/// ///
/// - **macOS:** Bounces the dock icon once. /// - **macOS:** Bounces the dock icon once.
/// - **Windows:** Flashes the taskbar button until the application is in focus. /// - **Windows:** Flashes the taskbar button until the application is in focus.
#[default]
Informational, Informational,
} }
impl Default for UserAttentionType {
fn default() -> Self {
UserAttentionType::Informational
}
}
bitflags! { bitflags! {
pub struct WindowButtons: u32 { pub struct WindowButtons: u32 {
const CLOSE = 1 << 0; const CLOSE = 1 << 0;
@ -1543,24 +1535,21 @@ bitflags! {
/// ## Platform-specific /// ## Platform-specific
/// ///
/// - **iOS / Android / Web / Wayland:** Unsupported. /// - **iOS / Android / Web / Wayland:** Unsupported.
#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[derive(Debug, Default, PartialEq, Eq, Clone, Copy)]
pub enum WindowLevel { pub enum WindowLevel {
/// The window will always be below normal windows. /// The window will always be below normal windows.
/// ///
/// This is useful for a widget-based app. /// This is useful for a widget-based app.
AlwaysOnBottom, AlwaysOnBottom,
/// The default. /// The default.
#[default]
Normal, Normal,
/// The window will always be on top of normal windows. /// The window will always be on top of normal windows.
AlwaysOnTop, AlwaysOnTop,
} }
impl Default for WindowLevel {
fn default() -> Self {
Self::Normal
}
}
/// Generic IME purposes for use in [`Window::set_ime_purpose`]. /// Generic IME purposes for use in [`Window::set_ime_purpose`].
/// ///
/// The purpose may improve UX by optimizing the IME for the specific use case, /// The purpose may improve UX by optimizing the IME for the specific use case,