diff --git a/src/cli.rs b/src/cli.rs index 09050b4a..866457e9 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -191,10 +191,11 @@ pub enum CliBackend { Metal, } -#[derive(ValueEnum, Debug, Copy, Clone, Hash)] +#[derive(ValueEnum, Debug, Copy, Clone, Hash, Default)] pub enum CliLogLevel { Trace, Debug, + #[default] Info, Warn, Error, @@ -212,12 +213,6 @@ impl Into for CliLogLevel { } } -impl Default for CliLogLevel { - fn default() -> Self { - Self::Info - } -} - #[derive(Args, Debug)] pub struct GenerateArgs { /// The shell to generate completions for diff --git a/src/cli/idle.rs b/src/cli/idle.rs index 21ea21ad..3fe6443c 100644 --- a/src/cli/idle.rs +++ b/src/cli/idle.rs @@ -9,9 +9,10 @@ use { std::{cell::Cell, rc::Rc}, }; -#[derive(Subcommand, Debug)] +#[derive(Subcommand, Debug, Default)] pub enum IdleCmd { /// Print the idle status. + #[default] Status, /// Set the idle interval. Set(IdleSetArgs), @@ -19,12 +20,6 @@ pub enum IdleCmd { SetGracePeriod(IdleSetGracePeriodArgs), } -impl Default for IdleCmd { - fn default() -> Self { - Self::Status - } -} - #[derive(Args, Debug)] pub struct IdleSetArgs { /// The interval of inactivity after which to disable the screens. diff --git a/src/ifs/wl_surface/x_surface/xwindow.rs b/src/ifs/wl_surface/x_surface/xwindow.rs index 4c29833d..d4d44c0d 100644 --- a/src/ifs/wl_surface/x_surface/xwindow.rs +++ b/src/ifs/wl_surface/x_surface/xwindow.rs @@ -31,20 +31,15 @@ use { thiserror::Error, }; -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] pub enum XInputModel { None, + #[default] Passive, Local, Global, } -impl Default for XInputModel { - fn default() -> Self { - Self::Passive - } -} - #[derive(Default, Debug)] pub struct IcccmHints { pub flags: Cell, diff --git a/src/it/test_mem.rs b/src/it/test_mem.rs index edd6bedb..3ff49cd5 100644 --- a/src/it/test_mem.rs +++ b/src/it/test_mem.rs @@ -61,7 +61,7 @@ fn map(fd: c::c_int, size: usize) -> Result<*const [Cell], TestError> { if res == c::MAP_FAILED { bail!("Could not map memory: {}", OsError::default()); } - Ok(std::slice::from_raw_parts(res as _, size)) + Ok(ptr::slice_from_raw_parts(res as _, size)) } } diff --git a/src/main.rs b/src/main.rs index cd516e3f..c7354044 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,6 @@ clippy::unnecessary_unwrap, clippy::needless_return, clippy::missing_safety_doc, - clippy::collapsible_if, clippy::mut_from_ref, clippy::bool_comparison, clippy::collapsible_match, diff --git a/src/rect/region.rs b/src/rect/region.rs index fa2dbf69..bc1613c4 100644 --- a/src/rect/region.rs +++ b/src/rect/region.rs @@ -234,18 +234,13 @@ where } } -#[derive(Copy, Clone, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Debug, Default)] enum BuilderOp { + #[default] Add, Sub, } -impl Default for BuilderOp { - fn default() -> Self { - Self::Add - } -} - #[derive(Debug)] pub struct RegionBuilder { base: Rc, diff --git a/src/utils/mmap.rs b/src/utils/mmap.rs index de4db910..eeae5af7 100644 --- a/src/utils/mmap.rs +++ b/src/utils/mmap.rs @@ -20,7 +20,7 @@ pub fn mmap( Err(OsError::default()) } else { Ok(Mmapped { - ptr: unsafe { std::slice::from_raw_parts(res.cast(), len) }, + ptr: ptr::slice_from_raw_parts(res.cast(), len), }) } }