nightly clippy fixes

This commit is contained in:
Stephan Dilly 2021-09-10 11:19:32 +02:00
parent 33344e93e2
commit 8729530ba9
6 changed files with 46 additions and 48 deletions

View File

@ -776,19 +776,21 @@ impl App {
}
Action::DeleteBranch(branch_ref, false) => {
self.queue.push(
if let Some(name) = branch_ref.rsplit('/').next()
{
InternalEvent::Push(
name.to_string(),
false,
true,
)
} else {
InternalEvent::ShowErrorMsg(format!(
"Failed to find the branch name in {}",
branch_ref
))
},
branch_ref.rsplit('/').next().map_or_else(
|| {
InternalEvent::ShowErrorMsg(format!(
"Failed to find the branch name in {}",
branch_ref
))
},
|name| {
InternalEvent::Push(
name.to_string(),
false,
true,
)
},
),
);
flags.insert(NeedsUpdate::ALL);
self.select_branch_popup.update_branches()?;

View File

@ -354,23 +354,23 @@ impl BlameFileComponent {
///
fn get_rows(&self, width: usize) -> Vec<Row> {
if let Some(ref file_blame) = self.file_blame {
file_blame
.lines
.iter()
.enumerate()
.map(|(i, (blame_hunk, line))| {
self.get_line_blame(
width,
i,
(blame_hunk.as_ref(), line.as_ref()),
file_blame,
)
})
.collect()
} else {
vec![]
}
self.file_blame
.as_ref()
.map_or_else(Vec::new, |file_blame| {
file_blame
.lines
.iter()
.enumerate()
.map(|(i, (blame_hunk, line))| {
self.get_line_blame(
width,
i,
(blame_hunk.as_ref(), line.as_ref()),
file_blame,
)
})
.collect()
})
}
fn get_line_blame(

View File

@ -151,7 +151,7 @@ impl DetailsComponent {
#[allow(unstable_name_collisions, clippy::too_many_lines)]
fn get_text_info(&self) -> Vec<Spans> {
if let Some(ref data) = self.data {
self.data.as_ref().map_or_else(Vec::new, |data| {
let mut res = vec![
Spans::from(vec![
style_detail(&self.theme, &Detail::Author),
@ -235,9 +235,7 @@ impl DetailsComponent {
}
res
} else {
vec![]
}
})
}
fn move_scroll_top(&mut self, move_type: ScrollType) -> bool {

View File

@ -286,11 +286,10 @@ impl CommitList {
// commit tags
txt.push(Span::styled(
Cow::from(if let Some(tags) = tags {
format!(" {}", tags)
} else {
String::from("")
}),
Cow::from(tags.map_or_else(
|| String::from(""),
|tags| format!(" {}", tags),
)),
theme.tags(selected),
));

View File

@ -368,11 +368,9 @@ impl TagListComponent {
///
fn get_rows(&self) -> Vec<Row> {
if let Some(ref tags) = self.tags {
self.tags.as_ref().map_or_else(Vec::new, |tags| {
tags.iter().map(|tag| self.get_row(tag)).collect()
} else {
vec![]
}
})
}
///

View File

@ -181,15 +181,16 @@ impl Status {
chunks: &[tui::layout::Rect],
) {
if let Some(branch_name) = self.git_branch_name.last() {
let ahead_behind =
if let Some(state) = &self.git_branch_state {
let ahead_behind = self
.git_branch_state
.as_ref()
.map_or_else(String::new, |state| {
format!(
"\u{2191}{} \u{2193}{} ",
state.ahead, state.behind,
)
} else {
String::new()
};
});
let w = Paragraph::new(format!(
"{}{{{}}}",
ahead_behind, branch_name