oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git

layout/mod.rs: apply clippy lints

Commit
3816a444c2a7b2096fb3a05e7cab1751cfff39f6
Parent
dcb6d02
Author
emzywastaken <amiamemetoo@gmail.com>
Date
2025-12-15 19:56:07
- renamed `LayoutType::new` => `LayoutType::to_boxed_layout` as `new`
did not return `Self`

- removed method `LayoutType::from_str` and implemented `FromStr` Trait
instead.

Diff

diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index bee6b0a..a05ecb1 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -4,6 +4,8 @@ pub mod normie;
 pub mod tabbed;
 pub mod tiling;
 
+use std::str::FromStr;
+
 use x11rb::protocol::xproto::Window;
 
 pub type LayoutBox = Box<dyn Layout>;
@@ -24,7 +26,7 @@ pub enum LayoutType {
 }
 
 impl LayoutType {
-    pub fn new(&self) -> LayoutBox {
+    pub fn to_boxed_layout(&self) -> LayoutBox {
         match self {
             Self::Tiling => Box::new(tiling::TilingLayout),
             Self::Normie => Box::new(normie::NormieLayout),
@@ -53,8 +55,12 @@ impl LayoutType {
             Self::Tabbed => "tabbed",
         }
     }
+}
+
+impl FromStr for LayoutType {
+    type Err = String;
 
-    pub fn from_str(s: &str) -> Result<Self, String> {
+    fn from_str(s: &str) -> Result<Self, String> {
         match s.to_lowercase().as_str() {
             "tiling" => Ok(Self::Tiling),
             "normie" | "floating" => Ok(Self::Normie),
@@ -68,7 +74,7 @@ impl LayoutType {
 
 pub fn layout_from_str(s: &str) -> Result<LayoutBox, String> {
     let layout_type = LayoutType::from_str(s)?;
-    Ok(layout_type.new())
+    Ok(layout_type.to_boxed_layout())
 }
 
 pub fn next_layout(current_name: &str) -> &'static str {