aboutsummaryrefslogtreecommitdiff
path: root/helix-tui/src/widgets
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-11-04 12:01:17 +0000
committerBlaž Hrastnik2022-11-04 12:06:28 +0000
commitc2c1280f02b83a468da67d88350c199915427535 (patch)
treecd4306c1b7353bb960608e18c5633aa22c5d0204 /helix-tui/src/widgets
parent921d3510132b0bd89d4ac0a542371c3ae90e2e02 (diff)
Resolve a bunch of upcoming clippy lints
Diffstat (limited to 'helix-tui/src/widgets')
-rw-r--r--helix-tui/src/widgets/block.rs16
-rw-r--r--helix-tui/src/widgets/table.rs6
2 files changed, 7 insertions, 15 deletions
diff --git a/helix-tui/src/widgets/block.rs b/helix-tui/src/widgets/block.rs
index bd025a31..98f84abe 100644
--- a/helix-tui/src/widgets/block.rs
+++ b/helix-tui/src/widgets/block.rs
@@ -7,7 +7,7 @@ use crate::{
use helix_view::graphics::{Rect, Style};
/// Border render type. Defaults to [`BorderType::Plain`].
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BorderType {
Plain,
Rounded,
@@ -47,7 +47,7 @@ impl Default for BorderType {
/// .border_type(BorderType::Rounded)
/// .style(Style::default().bg(Color::Black));
/// ```
-#[derive(Debug, Default, Clone, PartialEq)]
+#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Block<'a> {
/// Optional title place on the upper left of the block
title: Option<Spans<'a>>,
@@ -187,16 +187,8 @@ impl<'a> Widget for Block<'a> {
}
if let Some(title) = self.title {
- let lx = if self.borders.intersects(Borders::LEFT) {
- 1
- } else {
- 0
- };
- let rx = if self.borders.intersects(Borders::RIGHT) {
- 1
- } else {
- 0
- };
+ let lx = u16::from(self.borders.intersects(Borders::LEFT));
+ let rx = u16::from(self.borders.intersects(Borders::RIGHT));
let width = area.width.saturating_sub(lx).saturating_sub(rx);
buf.set_spans(area.left() + lx, area.top(), &title, width);
}
diff --git a/helix-tui/src/widgets/table.rs b/helix-tui/src/widgets/table.rs
index eb03704e..a8f428a7 100644
--- a/helix-tui/src/widgets/table.rs
+++ b/helix-tui/src/widgets/table.rs
@@ -34,7 +34,7 @@ use std::collections::HashMap;
///
/// You can apply a [`Style`] on the entire [`Cell`] using [`Cell::style`] or rely on the styling
/// capabilities of [`Text`].
-#[derive(Debug, Clone, PartialEq, Default)]
+#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct Cell<'a> {
pub content: Text<'a>,
style: Style,
@@ -79,7 +79,7 @@ where
/// ```
///
/// By default, a row has a height of 1 but you can change this using [`Row::height`].
-#[derive(Debug, Clone, PartialEq, Default)]
+#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct Row<'a> {
pub cells: Vec<Cell<'a>>,
height: u16,
@@ -179,7 +179,7 @@ impl<'a> Row<'a> {
/// // ...and potentially show a symbol in front of the selection.
/// .highlight_symbol(">>");
/// ```
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Table<'a> {
/// A block to wrap the widget in
block: Option<Block<'a>>,