From 66af52ae70d23ff3e5909b7eea500b5b6be77a99 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Thu, 9 Jan 2025 17:38:44 +0100 Subject: [PATCH] rust 1.84 update --- asyncgit/src/sync/hunks.rs | 2 +- asyncgit/src/sync/staging/stage_tracked.rs | 2 +- filetreelist/src/filetree.rs | 2 +- src/components/commitlist.rs | 3 +-- src/components/diff.rs | 4 +--- src/components/revision_files.rs | 6 +++--- src/components/status_tree.rs | 2 +- src/components/utils/statustree.rs | 2 +- src/popups/file_revlog.rs | 5 +---- src/popups/fuzzy_find.rs | 2 +- src/popups/taglist.rs | 2 +- 11 files changed, 13 insertions(+), 19 deletions(-) diff --git a/asyncgit/src/sync/hunks.rs b/asyncgit/src/sync/hunks.rs index 672f9d66..85c3725e 100644 --- a/asyncgit/src/sync/hunks.rs +++ b/asyncgit/src/sync/hunks.rs @@ -25,7 +25,7 @@ pub fn stage_hunk( let mut opt = ApplyOptions::new(); opt.hunk_callback(|hunk| { - hunk.map_or(false, |hunk| { + hunk.is_some_and(|hunk| { let header = HunkHeader::from(hunk); hash(&header) == hunk_hash }) diff --git a/asyncgit/src/sync/staging/stage_tracked.rs b/asyncgit/src/sync/staging/stage_tracked.rs index 5d02cf21..2bfe315c 100644 --- a/asyncgit/src/sync/staging/stage_tracked.rs +++ b/asyncgit/src/sync/staging/stage_tracked.rs @@ -51,7 +51,7 @@ pub fn stage_lines( let blob_id = repo.blob(new_content.as_bytes())?; idx.id = blob_id; - idx.file_size = u32::try_conv(new_content.as_bytes().len())?; + idx.file_size = u32::try_conv(new_content.len())?; index.add(&idx)?; index.write()?; diff --git a/filetreelist/src/filetree.rs b/filetreelist/src/filetree.rs index 4b965957..023da8ca 100644 --- a/filetreelist/src/filetree.rs +++ b/filetreelist/src/filetree.rs @@ -114,7 +114,7 @@ impl FileTree { /// pub fn move_selection(&mut self, dir: MoveSelection) -> bool { - self.selection.map_or(false, |selection| { + self.selection.is_some_and(|selection| { let new_index = match dir { MoveSelection::Up => { self.selection_updown(selection, true) diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index 796b3f4c..52e4e7be 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -634,8 +634,7 @@ impl CommitList { ) => details .upstream .as_ref() - .map_or( - false, + .is_some_and( |upstream| { upstream.reference == remote_branch.reference }, diff --git a/src/components/diff.rs b/src/components/diff.rs index 5318e03a..2d2729dd 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -339,9 +339,7 @@ impl DiffComponent { for (i, hunk) in diff.hunks.iter().enumerate() { let hunk_selected = self.focused() - && self - .selected_hunk - .map_or(false, |s| s == i); + && self.selected_hunk.is_some_and(|s| s == i); if lines_added >= height as usize { break; diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs index 4c61179e..8a560716 100644 --- a/src/components/revision_files.rs +++ b/src/components/revision_files.rs @@ -81,7 +81,7 @@ impl RevisionFilesComponent { self.show()?; let same_id = - self.revision.as_ref().map_or(false, |c| c.id == commit); + self.revision.as_ref().is_some_and(|c| c.id == commit); if !same_id { self.files = None; @@ -187,7 +187,7 @@ impl RevisionFilesComponent { } fn blame(&self) -> bool { - self.selected_file_path().map_or(false, |path| { + self.selected_file_path().is_some_and(|path| { self.queue.push(InternalEvent::OpenPopup( StackablePopupOpen::BlameFile(BlameFileOpen { file_path: path, @@ -201,7 +201,7 @@ impl RevisionFilesComponent { } fn file_history(&self) -> bool { - self.selected_file_path().map_or(false, |path| { + self.selected_file_path().is_some_and(|path| { self.queue.push(InternalEvent::OpenPopup( StackablePopupOpen::FileRevlog(FileRevOpen::new( path, diff --git a/src/components/status_tree.rs b/src/components/status_tree.rs index af0cde79..4fb762c1 100644 --- a/src/components/status_tree.rs +++ b/src/components/status_tree.rs @@ -120,7 +120,7 @@ impl StatusTreeComponent { /// pub fn is_file_selected(&self) -> bool { - self.tree.selected_item().map_or(false, |item| { + self.tree.selected_item().is_some_and(|item| { match item.kind { FileTreeItemKind::File(_) => true, FileTreeItemKind::Path(..) => false, diff --git a/src/components/utils/statustree.rs b/src/components/utils/statustree.rs index 59c2b154..2118ab0e 100644 --- a/src/components/utils/statustree.rs +++ b/src/components/utils/statustree.rs @@ -129,7 +129,7 @@ impl StatusTree { /// pub fn move_selection(&mut self, dir: MoveSelection) -> bool { - self.selection.map_or(false, |selection| { + self.selection.is_some_and(|selection| { let selection_change = match dir { MoveSelection::Up => { self.selection_updown(selection, true) diff --git a/src/popups/file_revlog.rs b/src/popups/file_revlog.rs index 83b40145..c946323b 100644 --- a/src/popups/file_revlog.rs +++ b/src/popups/file_revlog.rs @@ -124,10 +124,7 @@ impl FileRevlogPopup { /// pub fn any_work_pending(&self) -> bool { self.git_diff.is_pending() - || self - .git_log - .as_ref() - .map_or(false, AsyncLog::is_pending) + || self.git_log.as_ref().is_some_and(AsyncLog::is_pending) } /// diff --git a/src/popups/fuzzy_find.rs b/src/popups/fuzzy_find.rs index df694844..f7f8b27a 100644 --- a/src/popups/fuzzy_find.rs +++ b/src/popups/fuzzy_find.rs @@ -190,7 +190,7 @@ impl FuzzyFindPopup { .map(|(idx, indices)| { let selected = self .selected_index - .map_or(false, |index| index == *idx); + .is_some_and(|index| index == *idx); let full_text = trim_length_left(&self.contents[*idx], width); let trim_length = diff --git a/src/popups/taglist.rs b/src/popups/taglist.rs index e4d474e6..8acda78e 100644 --- a/src/popups/taglist.rs +++ b/src/popups/taglist.rs @@ -448,7 +448,7 @@ impl TagListPopup { let is_tag_missing_on_remote = self .missing_remote_tags .as_ref() - .map_or(false, |missing_remote_tags| { + .is_some_and(|missing_remote_tags| { let remote_tag = format!("refs/tags/{}", tag.name); missing_remote_tags.contains(&remote_tag)