Skip to content

Commit 3080248

Browse files
author
Naseschwarz
committed
Fix clippy hints
1 parent 82bef1f commit 3080248

File tree

2 files changed

+28
-41
lines changed

2 files changed

+28
-41
lines changed

asyncgit/src/file_history.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,19 @@ impl From<git2::Delta> for FileHistoryEntryDelta {
4444
| git2::Delta::Ignored
4545
| git2::Delta::Unreadable
4646
| git2::Delta::Conflicted
47-
| git2::Delta::Untracked => FileHistoryEntryDelta::None,
48-
git2::Delta::Added => FileHistoryEntryDelta::Added,
49-
git2::Delta::Deleted => FileHistoryEntryDelta::Deleted,
50-
git2::Delta::Modified => FileHistoryEntryDelta::Modified,
51-
git2::Delta::Renamed => FileHistoryEntryDelta::Renamed,
52-
git2::Delta::Copied => FileHistoryEntryDelta::Copied,
53-
git2::Delta::Typechange => {
54-
FileHistoryEntryDelta::Typechange
55-
}
47+
| git2::Delta::Untracked => Self::None,
48+
git2::Delta::Added => Self::Added,
49+
git2::Delta::Deleted => Self::Deleted,
50+
git2::Delta::Modified => Self::Modified,
51+
git2::Delta::Renamed => Self::Renamed,
52+
git2::Delta::Copied => Self::Copied,
53+
git2::Delta::Typechange => Self::Typechange,
5654
}
5755
}
5856
}
5957

6058
///
61-
#[derive(Debug, Clone, PartialEq)]
59+
#[derive(Debug, Clone, PartialEq, Eq)]
6260
pub struct FileHistoryEntry {
6361
///
6462
pub commit: CommitId,
@@ -170,12 +168,7 @@ impl AsyncFileHistoryJob {
170168
-> Result<bool> {
171169
let file_path = file_path.clone();
172170

173-
if fun_name(
174-
file_path,
175-
results.clone(),
176-
repo,
177-
commit_id,
178-
)? {
171+
if fun_name(&file_path, &results, repo, commit_id)? {
179172
params.send(AsyncGitNotification::FileHistory)?;
180173
params.set_progress(AsyncFileHistoryResults(
181174
results.clone(),
@@ -222,8 +215,8 @@ impl AsyncFileHistoryJob {
222215
}
223216

224217
fn fun_name(
225-
file_path: Arc<RwLock<String>>,
226-
results: Arc<Mutex<Vec<FileHistoryEntry>>>,
218+
file_path: &Arc<RwLock<String>>,
219+
results: &Arc<Mutex<Vec<FileHistoryEntry>>>,
227220
repo: &Repository,
228221
commit_id: &CommitId,
229222
) -> Result<bool> {
@@ -246,7 +239,7 @@ fn fun_name(
246239

247240
let entry = FileHistoryEntry {
248241
commit: *commit_id,
249-
delta: delta.clone().into(),
242+
delta: delta.into(),
250243
info: commit_info,
251244
file_path: current_file_path.clone(),
252245
};

src/popups/file_revlog.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl FileRevlogPopup {
126126
|| self
127127
.git_history
128128
.as_ref()
129-
.map_or(false, AsyncSingleJob::is_pending)
129+
.is_some_and(AsyncSingleJob::is_pending)
130130
}
131131

132132
///
@@ -145,7 +145,7 @@ impl FileRevlogPopup {
145145
if self.visible {
146146
match event {
147147
AsyncGitNotification::FileHistory => {
148-
self.update_list()?
148+
self.update_list()?;
149149
}
150150
AsyncGitNotification::Diff => self.update_diff()?,
151151
_ => (),
@@ -193,8 +193,10 @@ impl FileRevlogPopup {
193193
}
194194

195195
pub fn update_list(&mut self) -> Result<()> {
196-
if let Some(progress) =
197-
self.git_history.as_ref().and_then(|job| job.progress())
196+
if let Some(progress) = self
197+
.git_history
198+
.as_ref()
199+
.and_then(asyncgit::asyncjob::AsyncSingleJob::progress)
198200
{
199201
let result = progress.extract_results()?;
200202

@@ -205,7 +207,7 @@ impl FileRevlogPopup {
205207

206208
let was_empty = self.items.is_empty();
207209

208-
self.items.extend(result.into_iter());
210+
self.items.extend(result);
209211

210212
if was_empty && !self.items.is_empty() {
211213
self.queue
@@ -221,8 +223,7 @@ impl FileRevlogPopup {
221223

222224
let commit_id = table_state.selected().and_then(|selected| {
223225
self.items
224-
.iter()
225-
.nth(selected)
226+
.get(selected)
226227
.as_ref()
227228
.map(|entry| entry.commit)
228229
});
@@ -323,10 +324,7 @@ impl FileRevlogPopup {
323324
.collect()
324325
}
325326

326-
fn move_selection(
327-
&mut self,
328-
scroll_type: ScrollType,
329-
) -> Result<()> {
327+
fn move_selection(&mut self, scroll_type: ScrollType) {
330328
let old_selection =
331329
self.table_state.get_mut().selected().unwrap_or(0);
332330
let max_selection = self.items.len().saturating_sub(1);
@@ -353,8 +351,6 @@ impl FileRevlogPopup {
353351
}
354352

355353
self.set_selection(new_selection);
356-
357-
Ok(())
358354
}
359355

360356
fn set_selection(&mut self, selection: usize) {
@@ -416,9 +412,7 @@ impl FileRevlogPopup {
416412
// at index 50. Subtracting the current offset from the selected index
417413
// yields the correct index in `self.items`, in this case 0.
418414
let mut adjusted_table_state = TableState::default()
419-
.with_selected(
420-
table_state.selected().map(|selected| selected),
421-
)
415+
.with_selected(table_state.selected())
422416
.with_offset(table_state.offset());
423417

424418
f.render_widget(Clear, area);
@@ -541,36 +535,36 @@ impl Component for FileRevlogPopup {
541535
}
542536
} else if key_match(key, self.key_config.keys.move_up)
543537
{
544-
self.move_selection(ScrollType::Up)?;
538+
self.move_selection(ScrollType::Up);
545539
} else if key_match(
546540
key,
547541
self.key_config.keys.move_down,
548542
) {
549-
self.move_selection(ScrollType::Down)?;
543+
self.move_selection(ScrollType::Down);
550544
} else if key_match(
551545
key,
552546
self.key_config.keys.shift_up,
553547
) || key_match(
554548
key,
555549
self.key_config.keys.home,
556550
) {
557-
self.move_selection(ScrollType::Home)?;
551+
self.move_selection(ScrollType::Home);
558552
} else if key_match(
559553
key,
560554
self.key_config.keys.shift_down,
561555
) || key_match(
562556
key,
563557
self.key_config.keys.end,
564558
) {
565-
self.move_selection(ScrollType::End)?;
559+
self.move_selection(ScrollType::End);
566560
} else if key_match(key, self.key_config.keys.page_up)
567561
{
568-
self.move_selection(ScrollType::PageUp)?;
562+
self.move_selection(ScrollType::PageUp);
569563
} else if key_match(
570564
key,
571565
self.key_config.keys.page_down,
572566
) {
573-
self.move_selection(ScrollType::PageDown)?;
567+
self.move_selection(ScrollType::PageDown);
574568
}
575569
}
576570

0 commit comments

Comments
 (0)