summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorextrawurst <mail@rusticorn.com>2024-02-19 11:27:34 +0100
committerextrawurst <776816+extrawurst@users.noreply.github.com>2024-02-19 11:36:38 +0100
commitacf4661c1eaade2b0f656d50682cfc897f68bb94 (patch)
tree3694836c385327fad71278423045144bbd466205 /src
parente7bc4084dac1aa5f373715dc8ce06459252b0820 (diff)
fix nighty and raise msrv
Diffstat (limited to 'src')
-rw-r--r--src/components/blame_file.rs1
-rw-r--r--src/components/branchlist.rs15
-rw-r--r--src/components/commit_details/details.rs1
-rw-r--r--src/components/commit_details/mod.rs2
-rw-r--r--src/components/commitlist.rs19
-rw-r--r--src/components/diff.rs5
-rw-r--r--src/components/help.rs2
-rw-r--r--src/components/mod.rs1
-rw-r--r--src/components/msg.rs2
-rw-r--r--src/components/revision_files.rs5
-rw-r--r--src/components/status_tree.rs3
-rw-r--r--src/components/submodules.rs6
-rw-r--r--src/components/syntax_text.rs5
-rw-r--r--src/components/taglist.rs1
-rw-r--r--src/components/textinput.rs1
-rw-r--r--src/components/utils/filetree.rs1
-rw-r--r--src/components/utils/logitems.rs8
-rw-r--r--src/keys/key_config.rs1
-rw-r--r--src/tabs/status.rs1
-rw-r--r--src/ui/scrollbar.rs1
-rw-r--r--src/ui/scrolllist.rs1
-rw-r--r--src/ui/style.rs1
22 files changed, 26 insertions, 57 deletions
diff --git a/src/components/blame_file.rs b/src/components/blame_file.rs
index 2a86aba5..85820bc8 100644
--- a/src/components/blame_file.rs
+++ b/src/components/blame_file.rs
@@ -26,7 +26,6 @@ use ratatui::{
widgets::{Block, Borders, Cell, Clear, Row, Table, TableState},
Frame,
};
-use std::convert::TryInto;
static NO_COMMIT_ID: &str = "0000000";
static NO_AUTHOR: &str = "<no author>";
diff --git a/src/components/branchlist.rs b/src/components/branchlist.rs
index d3cc147a..81ad9b98 100644
--- a/src/components/branchlist.rs
+++ b/src/components/branchlist.rs
@@ -36,7 +36,7 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Clear, Paragraph, Tabs},
Frame,
};
-use std::{cell::Cell, convert::TryInto};
+use std::cell::Cell;
use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr;
@@ -505,12 +505,10 @@ impl BranchListComponent {
.iter()
.enumerate()
.filter(|(index, b)| {
- b.local_details()
- .map(|details| {
- details.is_head
- && *index == self.selection as usize
- })
- .unwrap_or_default()
+ b.local_details().is_some_and(|details| {
+ details.is_head
+ && *index == self.selection as usize
+ })
})
.count() > 0
}
@@ -623,8 +621,7 @@ impl BranchListComponent {
let is_head = displaybranch
.local_details()
- .map(|details| details.is_head)
- .unwrap_or_default();
+ .is_some_and(|details| details.is_head);
let is_head_str =
if is_head { HEAD_SYMBOL } else { EMPTY_SYMBOL };
let upstream_tracking_str = match displaybranch.details {
diff --git a/src/components/commit_details/details.rs b/src/components/commit_details/details.rs
index e1bce3fd..cd24e1df 100644
--- a/src/components/commit_details/details.rs
+++ b/src/components/commit_details/details.rs
@@ -23,7 +23,6 @@ use ratatui::{
text::{Line, Span, Text},
Frame,
};
-use std::clone::Clone;
use std::{borrow::Cow, cell::Cell};
use sync::CommitTags;
diff --git a/src/components/commit_details/mod.rs b/src/components/commit_details/mod.rs
index e9cfd6b9..b8a42bcc 100644
--- a/src/components/commit_details/mod.rs
+++ b/src/components/commit_details/mod.rs
@@ -135,7 +135,7 @@ impl CommitDetailsComponent {
}
fn is_compare(&self) -> bool {
- self.commit.map(|p| p.other.is_some()).unwrap_or_default()
+ self.commit.is_some_and(|p| p.other.is_some())
}
}
diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs
index 9f2956b7..64e41e89 100644
--- a/src/components/commitlist.rs
+++ b/src/components/commitlist.rs
@@ -30,8 +30,8 @@ use ratatui::{
Frame,
};
use std::{
- borrow::Cow, cell::Cell, cmp, collections::BTreeMap,
- convert::TryFrom, rc::Rc, time::Instant,
+ borrow::Cow, cell::Cell, cmp, collections::BTreeMap, rc::Rc,
+ time::Instant,
};
const ELEMENTS_PER_LINE: usize = 9;
@@ -151,11 +151,7 @@ impl CommitList {
marked.windows(2).all(|w| w[0].0 + 1 == w[1].0);
let yank = if marked_consecutive {
- format!(
- "{}^..{}",
- first.1.to_string(),
- last.1.to_string()
- )
+ format!("{}^..{}", first.1, last.1)
} else {
marked
.iter()
@@ -248,8 +244,7 @@ impl CommitList {
//note: set highlights to none if there is no highlight
self.highlights = if highlighting
.as_ref()
- .map(|set| set.is_empty())
- .unwrap_or_default()
+ .is_some_and(|set| set.is_empty())
{
None
} else {
@@ -718,8 +713,7 @@ impl CommitList {
self.highlights
.as_ref()
- .map(|highlights| highlights.contains(&commit))
- .unwrap_or_default()
+ .is_some_and(|highlights| highlights.contains(&commit))
}
fn needs_data(&self, idx: usize, idx_max: usize) -> bool {
@@ -749,8 +743,7 @@ impl CommitList {
let index_in_sync = self
.items
.index_offset_raw()
- .map(|index| want_min == index)
- .unwrap_or_default();
+ .is_some_and(|index| want_min == index);
if !index_in_sync || !self.is_list_in_sync() || force {
let commits = sync::get_commits_info(
diff --git a/src/components/diff.rs b/src/components/diff.rs
index 557ce9d8..1c7e0622 100644
--- a/src/components/diff.rs
+++ b/src/components/diff.rs
@@ -146,10 +146,7 @@ impl DiffComponent {
}
///
fn can_scroll(&self) -> bool {
- self.diff
- .as_ref()
- .map(|diff| diff.lines > 1)
- .unwrap_or_default()
+ self.diff.as_ref().is_some_and(|diff| diff.lines > 1)
}
///
pub fn current(&self) -> (String, bool) {
diff --git a/src/components/help.rs b/src/components/help.rs
index 314e1a9d..451ce7d3 100644
--- a/src/components/help.rs
+++ b/src/components/help.rs
@@ -20,7 +20,7 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Clear, Paragraph},
Frame,
};
-use std::{borrow::Cow, cmp, convert::TryFrom};
+use std::{borrow::Cow, cmp};
use ui::style::SharedTheme;
///
diff --git a/src/components/mod.rs b/src/components/mod.rs
index 88a1a9a8..ae29777a 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -81,7 +81,6 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Paragraph, Wrap},
Frame,
};
-use std::convert::From;
/// creates accessors for a list of components
///
diff --git a/src/components/msg.rs b/src/components/msg.rs
index e7876505..7e461876 100644
--- a/src/components/msg.rs
+++ b/src/components/msg.rs
@@ -15,8 +15,8 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap},
Frame,
};
-use std::convert::TryFrom;
use ui::style::SharedTheme;
+
pub struct MsgComponent {
title: String,
msg: String,
diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs
index ef1b0297..62c3f685 100644
--- a/src/components/revision_files.rs
+++ b/src/components/revision_files.rs
@@ -30,7 +30,7 @@ use ratatui::{
Frame,
};
use std::{borrow::Cow, fmt::Write};
-use std::{collections::BTreeSet, convert::From, path::Path};
+use std::{collections::BTreeSet, path::Path};
use unicode_truncate::UnicodeTruncateStr;
use unicode_width::UnicodeWidthStr;
@@ -125,8 +125,7 @@ impl RevisionFilesComponent {
if self
.revision
.as_ref()
- .map(|commit| commit.id == result.commit)
- .unwrap_or_default()
+ .is_some_and(|commit| commit.id == result.commit)
{
if let Ok(last) = result.result {
let filenames: Vec<&Path> = last
diff --git a/src/components/status_tree.rs b/src/components/status_tree.rs
index 613460db..5c8c3692 100644
--- a/src/components/status_tree.rs
+++ b/src/components/status_tree.rs
@@ -18,7 +18,7 @@ use anyhow::Result;
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
use crossterm::event::Event;
use ratatui::{backend::Backend, layout::Rect, text::Span, Frame};
-use std::{borrow::Cow, cell::Cell, convert::From, path::Path};
+use std::{borrow::Cow, cell::Cell, path::Path};
//TODO: use new `filetreelist` crate
@@ -554,7 +554,6 @@ impl Component for StatusTreeComponent {
#[cfg(test)]
mod tests {
use super::*;
- use asyncgit::StatusItemType;
fn string_vec_to_status(items: &[&str]) -> Vec<StatusItem> {
items
diff --git a/src/components/submodules.rs b/src/components/submodules.rs
index f92d800a..1bff7497 100644
--- a/src/components/submodules.rs
+++ b/src/components/submodules.rs
@@ -26,7 +26,7 @@ use ratatui::{
widgets::{Block, Borders, Clear, Paragraph},
Frame,
};
-use std::{cell::Cell, convert::TryInto};
+use std::cell::Cell;
use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr;
@@ -296,9 +296,7 @@ impl SubmodulesListComponent {
}
fn can_open_submodule(&self) -> bool {
- self.selected_entry()
- .map(|s| s.status.is_in_wd())
- .unwrap_or_default()
+ self.selected_entry().is_some_and(|s| s.status.is_in_wd())
}
//TODO: dedup this almost identical with BranchListComponent
diff --git a/src/components/syntax_text.rs b/src/components/syntax_text.rs
index c1d908bb..f031fdb6 100644
--- a/src/components/syntax_text.rs
+++ b/src/components/syntax_text.rs
@@ -29,7 +29,7 @@ use ratatui::{
widgets::{Block, Borders, Wrap},
Frame,
};
-use std::{cell::Cell, convert::From, path::Path};
+use std::{cell::Cell, path::Path};
pub struct SyntaxTextComponent {
repo: RepoPathRef,
@@ -105,8 +105,7 @@ impl SyntaxTextComponent {
let already_loaded = self
.current_file
.as_ref()
- .map(|(current_file, _)| current_file == &path)
- .unwrap_or_default();
+ .is_some_and(|(current_file, _)| current_file == &path);
if !already_loaded {
//TODO: fetch file content async aswell
diff --git a/src/components/taglist.rs b/src/components/taglist.rs
index 18e83dab..a2c96e4a 100644
--- a/src/components/taglist.rs
+++ b/src/components/taglist.rs
@@ -36,7 +36,6 @@ use ratatui::{
},
Frame,
};
-use std::convert::TryInto;
use ui::style::SharedTheme;
///
diff --git a/src/components/textinput.rs b/src/components/textinput.rs
index e5fe3f4f..08633bed 100644
--- a/src/components/textinput.rs
+++ b/src/components/textinput.rs
@@ -21,7 +21,6 @@ use ratatui::{
};
use std::cell::Cell;
use std::cell::OnceCell;
-use std::convert::From;
use tui_textarea::{CursorMove, Input, Key, Scrolling, TextArea};
///
diff --git a/src/components/utils/filetree.rs b/src/components/utils/filetree.rs
index c39b3d2d..73ecfc74 100644
--- a/src/components/utils/filetree.rs
+++ b/src/components/utils/filetree.rs
@@ -4,7 +4,6 @@ use anyhow::{bail, Result};
use asyncgit::StatusItem;
use std::{
collections::BTreeSet,
- convert::TryFrom,
ffi::OsStr,
ops::{Index, IndexMut},
path::Path,
diff --git a/src/components/utils/logitems.rs b/src/components/utils/logitems.rs
index d6f8de79..73f7fffd 100644
--- a/src/components/utils/logitems.rs
+++ b/src/components/utils/logitems.rs
@@ -128,11 +128,9 @@ impl ItemBatch {
self.items.extend(commits.into_iter().map(|c| {
let id = c.id;
let mut entry = LogEntry::from(c);
- if highlighted
- .as_ref()
- .map(|highlighted| highlighted.contains(&id))
- .unwrap_or_default()
- {
+ if highlighted.as_ref().is_some_and(|highlighted| {
+ highlighted.contains(&id)
+ }) {
entry.highlighted = true;
}
entry
diff --git a/src/keys/key_config.rs b/src/keys/key_config.rs
index 5feb5606..9ba0c791 100644
--- a/src/keys/key_config.rs
+++ b/src/keys/key_config.rs
@@ -119,7 +119,6 @@ impl KeyConfig {
#[cfg(test)]
mod tests {
use super::*;
- use crossterm::event::{KeyCode, KeyModifiers};
use std::fs;
use std::io::Write;
use tempfile::NamedTempFile;
diff --git a/src/tabs/status.rs b/src/tabs/status.rs
index 4be13eb3..592d4d4e 100644
--- a/src/tabs/status.rs
+++ b/src/tabs/status.rs
@@ -32,7 +32,6 @@ use ratatui::{
style::{Color, Style},
widgets::{Block, BorderType, Borders, Paragraph},
};
-use std::convert::Into;
/// what part of the screen is focused
#[derive(PartialEq)]
diff --git a/src/ui/scrollbar.rs b/src/ui/scrollbar.rs
index f2e710d2..6e33a0b7 100644
--- a/src/ui/scrollbar.rs
+++ b/src/ui/scrollbar.rs
@@ -12,7 +12,6 @@ use ratatui::{
widgets::Widget,
Frame,
};
-use std::convert::TryFrom;
pub enum Orientation {
Vertical,
diff --git a/src/ui/scrolllist.rs b/src/ui/scrolllist.rs
index 6fdc4ed8..bf0b8a3b 100644
--- a/src/ui/scrolllist.rs
+++ b/src/ui/scrolllist.rs
@@ -8,7 +8,6 @@ use ratatui::{
widgets::{Block, Borders, List, ListItem, Widget},
Frame,
};
-use std::iter::Iterator;
///
struct ScrollableList<'b, L, S>
diff --git a/src/ui/style.rs b/src/ui/style.rs
index 7310721f..0ae9caeb 100644
--- a/src/ui/style.rs
+++ b/src/ui/style.rs
@@ -354,7 +354,6 @@ impl Default for Theme {
mod tests {
use super::*;
use pretty_assertions::assert_eq;
- use std::io::Write;
use tempfile::NamedTempFile;
#[test]