From 3d66bda86c92e1f4f7fd1059394ce763cca5d463 Mon Sep 17 00:00:00 2001 From: veeso Date: Mon, 16 Oct 2023 12:55:30 +0200 Subject: [PATCH] fix: lint --- Cargo.toml | 2 +- src/adapter/crossterm/event.rs | 4 ++-- src/core/event.rs | 5 +++-- src/core/props/layout.rs | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f2d20f4..be5aa89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" repository = "https://github.com/veeso/tui-realm" [dependencies] -bitflags = "=1.3" +bitflags = "2.4" crossterm = { version = "0.27", optional = true } lazy-regex = "3" serde = { version = "^1", features = ["derive"], optional = true } diff --git a/src/adapter/crossterm/event.rs b/src/adapter/crossterm/event.rs index 5365125..2f80f57 100644 --- a/src/adapter/crossterm/event.rs +++ b/src/adapter/crossterm/event.rs @@ -71,7 +71,7 @@ impl From for Key { impl From for KeyModifiers { fn from(k: XtermKeyModifiers) -> Self { - let mut km = KeyModifiers::empty(); + let mut km = KeyModifiers::NONE; if k.intersects(XtermKeyModifiers::SHIFT) { km.insert(KeyModifiers::SHIFT); } @@ -235,7 +235,7 @@ mod test { kind: XtermMouseEventKind::Moved, column: 0, row: 0, - modifiers: XtermKeyModifiers::empty(), + modifiers: XtermKeyModifiers::NONE, })), Event::None ); diff --git a/src/core/event.rs b/src/core/event.rs index 416a521..32cbdce 100644 --- a/src/core/event.rs +++ b/src/core/event.rs @@ -149,6 +149,7 @@ bitflags! { /// /// Defines special key states, such as shift, control, alt... #[cfg_attr(feature = "serialize", derive(Deserialize, Serialize), serde(tag = "type"))] + #[derive(Clone, Copy, Hash, Eq, PartialEq, Debug, PartialOrd, Ord)] pub struct KeyModifiers: u8 { const NONE = 0b0000_0000; const SHIFT = 0b0000_0001; @@ -165,7 +166,7 @@ impl KeyEvent { impl From for KeyEvent { fn from(k: Key) -> Self { - Self::new(k, KeyModifiers::empty()) + Self::new(k, KeyModifiers::NONE) } } @@ -224,7 +225,7 @@ mod test { fn key_event_from_key() { let k = KeyEvent::from(Key::Up); assert_eq!(k.code, Key::Up); - assert_eq!(k.modifiers, KeyModifiers::empty()); + assert_eq!(k.modifiers, KeyModifiers::NONE); } #[test] diff --git a/src/core/props/layout.rs b/src/core/props/layout.rs index a02d77f..80f8438 100644 --- a/src/core/props/layout.rs +++ b/src/core/props/layout.rs @@ -61,7 +61,7 @@ impl Layout { /// Split an `Area` into chunks using the current layout configuration pub fn chunks(&self, area: Rect) -> Vec { TuiLayout::default() - .direction(self.direction.clone()) + .direction(self.direction) .horizontal_margin(self.margin.horizontal) .vertical_margin(self.margin.vertical) .constraints::<&[Constraint]>(self.constraints.as_ref())