summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Macovei <alexnmaco@gmail.com>2022-10-19 14:45:12 +0300
committerGitHub <noreply@github.com>2022-10-19 13:45:12 +0200
commit6b5745f6c24e11b2def9df13aa49c74fb6ba187a (patch)
treef1aac11b6f2cbc0909e883788997021addd0b3a3
parente2a0f3800fa57d53d462f99da575e5538ea85cdb (diff)
Fix Clippy Lints (#1390)
* apply latest nigtly clippy lints * temporarily disable const fn lints due to nigh false positive count on nightly
-rw-r--r--asyncgit/src/asyncjob/mod.rs8
-rw-r--r--asyncgit/src/error.rs4
-rw-r--r--asyncgit/src/sync/blame.rs15
-rw-r--r--asyncgit/src/sync/branch/merge_commit.rs4
-rw-r--r--asyncgit/src/sync/branch/mod.rs2
-rw-r--r--asyncgit/src/sync/branch/rename.rs6
-rw-r--r--asyncgit/src/sync/commit.rs2
-rw-r--r--asyncgit/src/sync/commit_details.rs4
-rw-r--r--asyncgit/src/sync/commits_info.rs7
-rw-r--r--asyncgit/src/sync/hooks.rs6
-rw-r--r--asyncgit/src/sync/logwalker.rs6
-rw-r--r--asyncgit/src/sync/mod.rs18
-rw-r--r--asyncgit/src/sync/rebase.rs2
-rw-r--r--asyncgit/src/sync/remotes/mod.rs6
-rw-r--r--asyncgit/src/sync/remotes/push.rs14
-rw-r--r--asyncgit/src/sync/remotes/tags.rs2
-rw-r--r--asyncgit/src/sync/staging/stage_tracked.rs2
-rw-r--r--asyncgit/src/sync/tags.rs2
-rw-r--r--src/app.rs2
-rw-r--r--src/components/branchlist.rs2
-rw-r--r--src/components/commit.rs2
-rw-r--r--src/components/commitlist.rs8
-rw-r--r--src/components/create_branch.rs2
-rw-r--r--src/components/diff.rs11
-rw-r--r--src/components/file_revlog.rs2
-rw-r--r--src/components/options_popup.rs2
-rw-r--r--src/components/pull.rs2
-rw-r--r--src/components/push.rs2
-rw-r--r--src/components/push_tags.rs2
-rw-r--r--src/components/rename_branch.rs2
-rw-r--r--src/components/status_tree.rs4
-rw-r--r--src/components/submodules.rs2
-rw-r--r--src/components/tag_commit.rs2
-rw-r--r--src/components/textinput.rs2
-rw-r--r--src/components/utils/logitems.rs2
-rw-r--r--src/components/utils/mod.rs4
-rw-r--r--src/components/utils/statustree.rs4
-rw-r--r--src/main.rs10
-rw-r--r--src/strings.rs20
-rw-r--r--src/tabs/stashlist.rs2
-rw-r--r--src/tabs/status.rs2
-rw-r--r--src/ui/mod.rs4
-rw-r--r--src/ui/reflow.rs8
43 files changed, 106 insertions, 109 deletions
diff --git a/asyncgit/src/asyncjob/mod.rs b/asyncgit/src/asyncjob/mod.rs
index 258faa0e..d17d2932 100644
--- a/asyncgit/src/asyncjob/mod.rs
+++ b/asyncgit/src/asyncjob/mod.rs
@@ -207,7 +207,7 @@ mod test {
let res =
self.v.fetch_add(self.value_to_add, Ordering::SeqCst);
- println!("[job] value: {}", res);
+ println!("[job] value: {res}");
Ok(())
}
@@ -236,8 +236,8 @@ mod test {
}
println!("recv");
- let _foo = receiver.recv().unwrap();
- let _foo = receiver.recv().unwrap();
+ receiver.recv().unwrap();
+ receiver.recv().unwrap();
assert!(receiver.is_empty());
assert_eq!(
@@ -282,7 +282,7 @@ mod test {
wait_for_job(&job);
println!("recv");
- let _foo = receiver.recv().unwrap();
+ receiver.recv().unwrap();
println!("received");
assert_eq!(
diff --git a/asyncgit/src/error.rs b/asyncgit/src/error.rs
index 5cbed38b..9078e314 100644
--- a/asyncgit/src/error.rs
+++ b/asyncgit/src/error.rs
@@ -83,12 +83,12 @@ pub type Result<T> = std::result::Result<T, Error>;
impl<T> From<std::sync::PoisonError<T>> for Error {
fn from(error: std::sync::PoisonError<T>) -> Self {
- Self::Generic(format!("poison error: {}", error))
+ Self::Generic(format!("poison error: {error}"))
}
}
impl<T> From<crossbeam_channel::SendError<T>> for Error {
fn from(error: crossbeam_channel::SendError<T>) -> Self {
- Self::Generic(format!("send error: {}", error))
+ Self::Generic(format!("send error: {error}"))
}
}
diff --git a/asyncgit/src/sync/blame.rs b/asyncgit/src/sync/blame.rs
index 09d00855..eba952fc 100644
--- a/asyncgit/src/sync/blame.rs
+++ b/asyncgit/src/sync/blame.rs
@@ -170,10 +170,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();
- assert!(matches!(
- blame_file(&repo_path, "foo", None),
- Err(_)
- ));
+ assert!(matches!(blame_file(repo_path, "foo", None), Err(_)));
File::create(&root.join(file_path))?
.write_all(b"line 1\n")?;
@@ -181,7 +178,7 @@ mod tests {
stage_add_file(repo_path, file_path)?;
commit(repo_path, "first commit")?;
- let blame = blame_file(&repo_path, "foo", None)?;
+ let blame = blame_file(repo_path, "foo", None)?;
assert!(matches!(
blame.lines.as_slice(),
@@ -205,7 +202,7 @@ mod tests {
stage_add_file(repo_path, file_path)?;
commit(repo_path, "second commit")?;
- let blame = blame_file(&repo_path, "foo", None)?;
+ let blame = blame_file(repo_path, "foo", None)?;
assert!(matches!(
blame.lines.as_slice(),
@@ -232,14 +229,14 @@ mod tests {
file.write(b"line 3\n")?;
- let blame = blame_file(&repo_path, "foo", None)?;
+ let blame = blame_file(repo_path, "foo", None)?;
assert_eq!(blame.lines.len(), 2);
stage_add_file(repo_path, file_path)?;
commit(repo_path, "third commit")?;
- let blame = blame_file(&repo_path, "foo", None)?;
+ let blame = blame_file(repo_path, "foo", None)?;
assert_eq!(blame.lines.len(), 3);
@@ -264,6 +261,6 @@ mod tests {
stage_add_file(repo_path, file_path).unwrap();
commit(repo_path, "first commit").unwrap();
- assert!(blame_file(&repo_path, "bar\\foo", None).is_ok());
+ assert!(blame_file(repo_path, "bar\\foo", None).is_ok());
}
}
diff --git a/asyncgit/src/sync/branch/merge_commit.rs b/asyncgit/src/sync/branch/merge_commit.rs
index 50d7dc39..f3d5bf10 100644
--- a/asyncgit/src/sync/branch/merge_commit.rs
+++ b/asyncgit/src/sync/branch/merge_commit.rs
@@ -158,7 +158,7 @@ mod test {
false,
false,
None,
- None.into(),
+ None,
)
.is_err());
@@ -195,7 +195,7 @@ mod test {
//verify commit msg
let details = crate::sync::get_commit_details(
&clone2_dir.into(),
- merge_commit.into(),
+ merge_commit,
)
.unwrap();
assert_eq!(
diff --git a/asyncgit/src/sync/branch/mod.rs b/asyncgit/src/sync/branch/mod.rs
index 327a3de1..c72a4845 100644
--- a/asyncgit/src/sync/branch/mod.rs
+++ b/asyncgit/src/sync/branch/mod.rs
@@ -206,7 +206,7 @@ pub(crate) fn branch_set_upstream(
if branch.upstream().is_err() {
let remote = get_default_remote_in_repo(repo)?;
- let upstream_name = format!("{}/{}", remote, branch_name);
+ let upstream_name = format!("{remote}/{branch_name}");
branch.set_upstream(Some(upstream_name.as_str()))?;
}
diff --git a/asyncgit/src/sync/branch/rename.rs b/asyncgit/src/sync/branch/rename.rs
index 2b648dee..90ca31c2 100644
--- a/asyncgit/src/sync/branch/rename.rs
+++ b/asyncgit/src/sync/branch/rename.rs
@@ -24,7 +24,7 @@ pub fn rename_branch(
#[cfg(test)]
mod test {
- use super::super::*;
+ use super::super::{checkout_branch, create_branch, RepoPath};
use super::rename_branch;
use crate::sync::tests::repo_init;
@@ -42,7 +42,7 @@ mod test {
assert_eq!(
repo.branches(None)
.unwrap()
- .nth(0)
+ .next()
.unwrap()
.unwrap()
.0
@@ -58,7 +58,7 @@ mod test {
assert_eq!(
repo.branches(None)
.unwrap()
- .nth(0)
+ .next()
.unwrap()
.unwrap()
.0
diff --git a/asyncgit/src/sync/commit.rs b/asyncgit/src/sync/commit.rs
index b8754581..07d98feb 100644
--- a/asyncgit/src/sync/commit.rs
+++ b/asyncgit/src/sync/commit.rs
@@ -138,7 +138,7 @@ mod tests {
fn count_commits(repo: &Repository, max: usize) -> usize {
let mut items = Vec::new();
- let mut walk = LogWalker::new(&repo, max).unwrap();
+ let mut walk = LogWalker::new(repo, max).unwrap();
walk.read(&mut items).unwrap();
items.len()
}
diff --git a/asyncgit/src/sync/commit_details.rs b/asyncgit/src/sync/commit_details.rs
index 02395d1e..e3cc4810 100644
--- a/asyncgit/src/sync/commit_details.rs
+++ b/asyncgit/src/sync/commit_details.rs
@@ -60,7 +60,7 @@ impl CommitMessage {
///
pub fn combine(self) -> String {
if let Some(body) = self.body {
- format!("{}\n{}", self.subject, body)
+ format!("{}\n{body}", self.subject)
} else {
self.subject
}
@@ -82,6 +82,8 @@ pub struct CommitDetails {
impl CommitDetails {
///
+ #[allow(clippy::missing_const_for_fn)]
+ // clippy doesn't realise indexing a String is not const
pub fn short_hash(&self) -> &str {
&self.hash[0..7]
}
diff --git a/asyncgit/src/sync/commits_info.rs b/asyncgit/src/sync/commits_info.rs
index 14b24376..2c877b9a 100644
--- a/asyncgit/src/sync/commits_info.rs
+++ b/asyncgit/src/sync/commits_info.rs
@@ -164,8 +164,7 @@ mod tests {
stage_add_file(repo_path, file_path).unwrap();
let c2 = commit(repo_path, "commit2").unwrap();
- let res =
- get_commits_info(repo_path, &vec![c2, c1], 50).unwrap();
+ let res = get_commits_info(repo_path, &[c2, c1], 50).unwrap();
assert_eq!(res.len(), 2);
assert_eq!(res[0].message.as_str(), "commit2");
@@ -187,7 +186,7 @@ mod tests {
stage_add_file(repo_path, file_path).unwrap();
let c1 = commit(repo_path, "subject\nbody").unwrap();
- let res = get_commits_info(repo_path, &vec![c1], 50).unwrap();
+ let res = get_commits_info(repo_path, &[c1], 50).unwrap();
assert_eq!(res.len(), 1);
assert_eq!(res[0].message.as_str(), "subject");
@@ -211,7 +210,7 @@ mod tests {
let res = get_commits_info(
repo_path,
- &vec![get_head_repo(&repo).unwrap().into()],
+ &[get_head_repo(&repo).unwrap()],
50,
)
.unwrap();
diff --git a/asyncgit/src/sync/hooks.rs b/asyncgit/src/sync/hooks.rs
index 5265632b..3a4b3758 100644
--- a/asyncgit/src/sync/hooks.rs
+++ b/asyncgit/src/sync/hooks.rs
@@ -87,7 +87,7 @@ impl HookPaths {
} else {
let err = String::from_utf8_lossy(&output.stderr);
let out = String::from_utf8_lossy(&output.stdout);
- let formatted = format!("{}{}", out, err);
+ let formatted = format!("{out}{err}");
Ok(HookResult::NotOk(formatted))
}
@@ -324,7 +324,7 @@ exit 1
let workdir = TempDir::new().unwrap();
let git_root = git_root.into_path();
let repo_path = &RepoPath::Workdir {
- gitdir: dbg!(git_root.to_path_buf()),
+ gitdir: dbg!(git_root),
workdir: dbg!(workdir.into_path()),
};
@@ -541,7 +541,7 @@ exit 1
let workdir = TempDir::new().unwrap();
let git_root = git_root.into_path();
let repo_path = &RepoPath::Workdir {
- gitdir: dbg!(git_root.to_path_buf()),
+ gitdir: dbg!(git_root),
workdir: dbg!(workdir.path().to_path_buf()),
};
diff --git a/asyncgit/src/sync/logwalker.rs b/asyncgit/src/sync/logwalker.rs
index 15873e29..3f9110b1 100644
--- a/asyncgit/src/sync/logwalker.rs
+++ b/asyncgit/src/sync/logwalker.rs
@@ -162,7 +162,7 @@ mod tests {
walk.read(&mut items).unwrap();
assert_eq!(items.len(), 1);
- assert_eq!(items[0], oid2.into());
+ assert_eq!(items[0], oid2);
Ok(())
}
@@ -190,7 +190,7 @@ mod tests {
dbg!(&info);
assert_eq!(items.len(), 2);
- assert_eq!(items[0], oid2.into());
+ assert_eq!(items[0], oid2);
let mut items = Vec::new();
walk.read(&mut items).unwrap();
@@ -235,7 +235,7 @@ mod tests {
walker.read(&mut items).unwrap();
assert_eq!(items.len(), 1);
- assert_eq!(items[0], second_commit_id.into());
+ assert_eq!(items[0], second_commit_id);
let mut items = Vec::new();
walker.read(&mut items).unwrap();
diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs
index 7a72b69f..ed305b4a 100644
--- a/asyncgit/src/sync/mod.rs
+++ b/asyncgit/src/sync/mod.rs
@@ -125,10 +125,10 @@ mod tests {
let temp_dir = TempDir::new().unwrap();
let path = temp_dir.path();
- set_search_path(ConfigLevel::System, &path).unwrap();
- set_search_path(ConfigLevel::Global, &path).unwrap();
- set_search_path(ConfigLevel::XDG, &path).unwrap();
- set_search_path(ConfigLevel::ProgramData, &path).unwrap();
+ set_search_path(ConfigLevel::System, path).unwrap();
+ set_search_path(ConfigLevel::Global, path).unwrap();
+ set_search_path(ConfigLevel::XDG, path).unwrap();
+ set_search_path(ConfigLevel::ProgramData, path).unwrap();
});
}
@@ -279,7 +279,7 @@ mod tests {
.try_init();
}
- /// Same as repo_init, but the repo is a bare repo (--bare)
+ /// Same as `repo_init`, but the repo is a bare repo (--bare)
pub fn repo_init_bare() -> Result<(TempDir, Repository)> {
init_log();
@@ -303,7 +303,7 @@ mod tests {
///
pub fn debug_cmd_print(path: &RepoPath, cmd: &str) {
let cmd = debug_cmd(path, cmd);
- eprintln!("\n----\n{}", cmd);
+ eprintln!("\n----\n{cmd}");
}
/// helper to fetch commmit details using log walker
@@ -323,7 +323,7 @@ mod tests {
fn debug_cmd(path: &RepoPath, cmd: &str) -> String {
let output = if cfg!(target_os = "windows") {
Command::new("cmd")
- .args(&["/C", cmd])
+ .args(["/C", cmd])
.current_dir(path.gitpath())
.output()
.unwrap()
@@ -343,12 +343,12 @@ mod tests {
if stdout.is_empty() {
String::new()
} else {
- format!("out:\n{}", stdout)
+ format!("out:\n{stdout}")
},
if stderr.is_empty() {
String::new()
} else {
- format!("err:\n{}", stderr)
+ format!("err:\n{stderr}")
}
)
}
diff --git a/asyncgit/src/sync/rebase.rs b/asyncgit/src/sync/rebase.rs
index 8040ee96..a21438ee 100644
--- a/asyncgit/src/sync/rebase.rs
+++ b/asyncgit/src/sync/rebase.rs
@@ -202,7 +202,7 @@ mod test_conflict_free_rebase {
.find_commit(c.into())
.unwrap()
.parent_ids()
- .map(|id| CommitId::from(id))
+ .map(CommitId::from)
.collect();
foo
diff --git a/asyncgit/src/sync/remotes/mod.rs b/asyncgit/src/sync/remotes/mod.rs
index 228206fd..d17df4c6 100644
--- a/asyncgit/src/sync/remotes/mod.rs
+++ b/asyncgit/src/sync/remotes/mod.rs
@@ -216,7 +216,7 @@ mod tests {
debug_cmd_print(
repo_path,
- &format!("git remote add second {}", remote_path)[..],
+ &format!("git remote add second {remote_path}")[..],
);
let remotes = get_remotes(repo_path).unwrap();
@@ -251,7 +251,7 @@ mod tests {
debug_cmd_print(
repo_path,
- &format!("git remote add origin {}", remote_path)[..],
+ &format!("git remote add origin {remote_path}")[..],
);
//NOTE: aparently remotes are not chronolically sorted but alphabetically
@@ -287,7 +287,7 @@ mod tests {
debug_cmd_print(
repo_path,
- &format!("git remote add someremote {}", remote_path)[..],
+ &format!("git remote add someremote {remote_path}")[..],
);
let remotes = get_remotes(repo_path).unwrap();
diff --git a/asyncgit/src/sync/remotes/push.rs b/asyncgit/src/sync/remotes/push.rs
index 7467b5fe..5e75eda8 100644
--- a/asyncgit/src/sync/remotes/push.rs
+++ b/asyncgit/src/sync/remotes/push.rs
@@ -164,7 +164,7 @@ pub fn push_raw(
};
let branch_name =
- format!("{}refs/{}/{}", branch_modifier, ref_type, branch);
+ format!("{branch_modifier}refs/{ref_type}/{branch}");
remote.push(&[branch_name.as_str()], Some(&mut options))?;
if let Some((reference, msg)) =
@@ -488,11 +488,9 @@ mod tests {
upstream_repo
.branches(None)
.unwrap()
- .map(|i| i.unwrap())
+ .map(std::result::Result::unwrap)
.map(|(i, _)| i.name().unwrap().unwrap().to_string())
- .filter(|i| i == "test_branch")
- .next()
- .is_some(),
+ .any(|i| &i == "test_branch"),
true
);
@@ -516,11 +514,9 @@ mod tests {
upstream_repo
.branches(None)
.unwrap()
- .map(|i| i.unwrap())
+ .map(std::result::Result::unwrap)
.map(|(i, _)| i.name().unwrap().unwrap().to_string())
- .filter(|i| i == "test_branch")
- .next()
- .is_some(),
+ .any(|i| &i == "test_branch"),
false
);
}
diff --git a/asyncgit/src/sync/remotes/tags.rs b/asyncgit/src/sync/remotes/tags.rs
index 235ababc..138977b8 100644
--- a/asyncgit/src/sync/remotes/tags.rs
+++ b/asyncgit/src/sync/remotes/tags.rs
@@ -89,7 +89,7 @@ pub fn tags_missing_remote(
let mut local_tags = tags
.iter()
- .filter_map(|tag| tag.map(|tag| format!("refs/tags/{}", tag)))
+ .filter_map(|tag| tag.map(|tag| format!("refs/tags/{tag}")))
.collect::<HashSet<_>>();
let remote_tags =
remote_tag_refs(repo_path, remote, basic_credential)?;
diff --git a/asyncgit/src/sync/staging/stage_tracked.rs b/asyncgit/src/sync/staging/stage_tracked.rs
index 5f9861a1..5d02cf21 100644
--- a/asyncgit/src/sync/staging/stage_tracked.rs
+++ b/asyncgit/src/sync/staging/stage_tracked.rs
@@ -163,7 +163,7 @@ c = 4";
assert_eq!(get_statuses(path), (1, 0));
- stage_add_file(path, &Path::new("test.txt")).unwrap();
+ stage_add_file(path, Path::new("test.txt")).unwrap();
assert_eq!(get_statuses(path), (0, 1));
diff --git a/asyncgit/src/sync/tags.rs b/asyncgit/src/sync/tags.rs
index 700c46fd..34d0f2d1 100644
--- a/asyncgit/src/sync/tags.rs
+++ b/asyncgit/src/sync/tags.rs
@@ -20,6 +20,8 @@ pub struct Tag {
impl Tag {
///
+ #[allow(clippy::missing_const_for_fn)]
+ // clippy doesn't realise allocating a String is not const
pub fn new(name: &str) -> Self {
Self {
name: name.into(),
diff --git a/src/app.rs b/src/app.rs
index 894373bc..56fe2a50 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -448,7 +448,7 @@ impl App {
if let Err(e) = result {
let msg =
- format!("failed to launch editor:\n{}", e);
+ format!("failed to launch editor:\n{e}");
log::error!("{}", msg.as_str());
self.msg.show_error(msg.as_str())?;
}
diff --git a/src/components/branchlist.rs b/src/components/branchlist.rs
index a23933d1..64c8fc8e 100644
--- a/src/components/branchlist.rs
+++ b/src/components/branchlist.rs
@@ -609,7 +609,7 @@ impl BranchListComponent {
};
let span_prefix = Span::styled(
- format!("{}{} ", is_head_str, upstream_tracking_str),
+ format!("{is_head_str}{upstream_tracking_str} "),
theme.commit_author(selected),
);
let span_hash = Span::styled(
diff --git a/src/components/commit.rs b/src/components/commit.rs
index 8f5c193d..70d67daf 100644
--- a/src/components/commit.rs
+++ b/src/components/commit.rs
@@ -94,7 +94,7 @@ impl CommitComponent {
fn draw_branch_name<B: Backend>(&self, f: &mut Frame<B>) {
if let Some(name) = self.git_branch_name.last() {
- let w = Paragraph::new(format!("{{{}}}", name))
+ let w = Paragraph::new(format!("{{{name}}}"))
.alignment(Alignment::Right);
let rect = {
diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs
index 0a901b03..ec92b123 100644
--- a/src/components/commitlist.rs
+++ b/src/components/commitlist.rs
@@ -366,7 +366,7 @@ impl CommitList {
txt.push(splitter.clone());
let author_width =
- (width.saturating_sub(19) / 3).max(3).min(20);
+ (width.saturating_sub(19) / 3).clamp(3, 20);
let author = string_width_align(&e.author, author_width);
// commit author
@@ -399,7 +399,7 @@ impl CommitList {
// commit msg
txt.push(Span::styled(
- format!("{:w$}", &e.msg, w = message_width),
+ format!("{:message_width$}", &e.msg),
theme.text(true, selected),
));
@@ -434,7 +434,7 @@ impl CommitList {
let branches = self.branches.get(&e.id).map(|names| {
names
.iter()
- .map(|name| format!("{{{}}}", name))
+ .map(|name| format!("{{{name}}}"))
.join(" ")
});
@@ -502,7 +502,7 @@ impl DrawableComponent for CommitList {
));
let branch_post_fix =
- self.branch.as_ref().map(|b| format!("- {{{}}}", b));
+ self.branch.as_ref().map(|b| format!("- {{{b}}}"));
let title = format!(
"{} {}/{} {}",
diff --git a/src/components/create_branch.rs b/src/components/create_branch.rs
index a5c784ff..393eb54e 100644
--- a/src/components/create_branch.rs
+++ b/src/components/create_branch.rs
@@ -142,7 +142,7 @@ impl CreateBranchComponent {
Err(e) => {
log::error!("create branch: {}", e,);
self.queue.push(InternalEvent::ShowErrorMsg(
- format!("create branch error:\n{}", e,),
+ format!("create branch error:\n{e}",),
));
}
}
diff --git a/src/components/diff.rs b/src/components/diff.rs
index 7361c7b7..95d46e74 100644
--- a/src/components/diff.rs
+++ b/src/components/diff.rs
@@ -198,7 +198,7 @@ impl DiffComponent {
fn move_selection(&mut self, move_type: ScrollType) {
if let Some(diff) = &self.diff {
- let max = diff.lines.saturating_sub(1) as usize;
+ let max = diff.lines.saturating_sub(1);
let new_start = match move_type {
ScrollType::Down => {
@@ -229,7 +229,7 @@ impl DiffComponent {
fn update_selection(&mut self, new_start: usize) {
if let Some(diff) = &self.diff {
- let max = diff.lines.saturating_sub(1) as usize;
+ let max = diff.lines.saturating_sub(1);
let new_start = cmp::min(max, new_start);
self.selection = Selection::Single(new_start);
self.selected_hunk =
@@ -303,9 +303,8 @@ impl DiffComponent {
if let Some(diff) = &self.diff {
if diff.hunks.is_empty() {
let is_positive = diff.size_delta >= 0;
- let delta_byte_size = ByteSize::b(
- diff.size_delta.unsigned_abs() as u64,
- );
+ let delta_byte_size =
+ ByteSize::b(diff.size_delta.unsigned_abs());<