From bc85a860004295ecf7d265ab29bc1b3147a20777 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Thu, 2 Apr 2020 23:45:50 +0200 Subject: [PATCH] pedantic clippy --- src/components/changes.rs | 4 +++- src/components/diff.rs | 4 ++-- src/main.rs | 4 ++-- src/strings.rs | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/changes.rs b/src/components/changes.rs index 50b750e7..0454dfa4 100644 --- a/src/components/changes.rs +++ b/src/components/changes.rs @@ -89,7 +89,9 @@ impl ChangesComponent { i = cmp::min(i + delta, max - 1); i = cmp::max(i, 0); - self.selection = Some(i as usize); + if let Ok(i) = usize::try_from(i) { + self.selection = Some(i); + } } } } diff --git a/src/components/diff.rs b/src/components/diff.rs index 956fd7d9..4879453c 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -5,7 +5,7 @@ use crate::{ }; use asyncgit::{hash, Diff, DiffLine, DiffLineType}; use crossterm::event::{Event, KeyCode}; -use std::{borrow::Cow, cmp}; +use std::{borrow::Cow, cmp, convert::TryFrom}; use tui::{ backend::Backend, layout::{Alignment, Rect}, @@ -82,7 +82,7 @@ impl DiffComponent { break; } - let hunk_len = hunk.0.len() as u16; + let hunk_len = u16::try_from(hunk.0.len()).unwrap(); let hunk_min = line_cursor; let hunk_max = line_cursor + hunk_len; diff --git a/src/main.rs b/src/main.rs index 0df18c81..da8cf467 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ #![forbid(unsafe_code)] -#![deny(clippy::all)] // #![warn(clippy::cargo)] -#![deny(clippy::cast_possible_wrap)] +#![deny(clippy::pedantic)] +#![allow(clippy::module_name_repetitions)] mod app; mod components; diff --git a/src/strings.rs b/src/strings.rs index bd7cf531..1f392093 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -12,10 +12,10 @@ pub static CMD_STATUS_UNSTAGE: &str = "Unstage File [enter]"; pub static CMD_STATUS_RESET: &str = "Reset File [D]"; pub static CMD_STATUS_QUIT: &str = "Quit [esc,q]"; pub static CMD_STATUS_HELP: &str = "Help [h]"; -pub static CMD_STATUS_LEFT: &str = "Back [←]"; -pub static CMD_STATUS_RIGHT: &str = "Diff [→]"; +pub static CMD_STATUS_LEFT: &str = "Back [\u{2190}]"; //← +pub static CMD_STATUS_RIGHT: &str = "Diff [\u{2192}]"; //→ pub static CMD_SPLITTER: &str = " "; -pub static CMD_SCROLL: &str = "Scroll [↑↓]"; +pub static CMD_SCROLL: &str = "Scroll [\u{2191}\u{2193}]"; //↑↓ pub static COMMIT_TITLE: &str = "Commit"; pub static COMMIT_MSG: &str = "type commit message..";