From cebb1adea71a8e3cab34e900bc24ef6c4d74645a Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 9 Sep 2022 01:38:34 +0400 Subject: [PATCH] Fix Clippy warnings --- Makefile | 1 + src/api/settings.rs | 5 +---- src/settings.rs | 16 ++++++++-------- src/unit.rs | 12 ++++++------ 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 4f882b1..aaeb1e5 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,7 @@ test: $(TEST_EXE) @echo "$(TEST_EXE)" | awk '{ OFS="\n"; $$1=$$1 } 1' | /bin/sh $(CARGO) test $(CARGO) fmt --check + $(CARGO) clippy clean: rm -f $(ALL_OBJ) $(ALL_EXE) diff --git a/src/api/settings.rs b/src/api/settings.rs index 51fd92b..958670e 100644 --- a/src/api/settings.rs +++ b/src/api/settings.rs @@ -105,10 +105,7 @@ unsafe extern "C" fn settings_set_master_area_factor_per_unit(value: c_uchar) { #[no_mangle] unsafe extern "C" fn settings_get_max_clients_in_master() -> c_int { - match SETTINGS.unwrap().max_clients_in_master() { - None => 0, - Some(value) => value, - } + SETTINGS.unwrap().max_clients_in_master().unwrap_or(0) } #[no_mangle] diff --git a/src/settings.rs b/src/settings.rs index 463c3ec..ea03863 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -86,13 +86,13 @@ impl Default for ForSingleWindow { } } -impl Into for ForSingleWindow { - fn into(self) -> c_uchar { - match self { - Self::Never => 0, - Self::Always => 1, - Self::NotInFullscreen => 2, - Self::NobodyIsFullscreen => 3, +impl From for c_uchar { + fn from(value: ForSingleWindow) -> Self { + match value { + ForSingleWindow::Never => 0, + ForSingleWindow::Always => 1, + ForSingleWindow::NotInFullscreen => 2, + ForSingleWindow::NobodyIsFullscreen => 3, } } } @@ -176,7 +176,7 @@ impl Settings { // TODO: notify WM to rearrange clients pub fn max_clients_in_master_set(&mut self, value: Option) { self.max_clients_in_master = - value.map(|value| constraints::max_clients_in_master(value)); + value.map(constraints::max_clients_in_master); } pub fn respect_resize_hints_in_floating_layout(&self) -> bool { diff --git a/src/unit.rs b/src/unit.rs index 41a0fd5..78a34ce 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -7,12 +7,12 @@ pub enum Kind { Tag, } -impl Into for Kind { - fn into(self) -> c_uchar { - match self { - Self::Global => 0, - Self::Monitor => 1, - Self::Tag => 2, +impl From for c_uchar { + fn from(value: Kind) -> Self { + match value { + Kind::Global => 0, + Kind::Monitor => 1, + Kind::Tag => 2, } } }