Skip to content

Commit

Permalink
Remove unneeded call to collect
Browse files Browse the repository at this point in the history
  • Loading branch information
vacuus committed Dec 26, 2021
1 parent 83bde52 commit bbbeefd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,16 @@ impl clean::Generics {
cx: &'a Context<'tcx>,
) -> impl fmt::Display + 'a + Captures<'tcx> {
display_fn(move |f| {
let real_params =
self.params.iter().filter(|p| !p.is_synthetic_type_param()).collect::<Vec<_>>();
if real_params.is_empty() {
let mut real_params =
self.params.iter().filter(|p| !p.is_synthetic_type_param()).peekable();
if real_params.peek().is_none() {
return Ok(());
}

if f.alternate() {
write!(f, "<{:#}>", comma_sep(real_params.iter().map(|g| g.print(cx))))
write!(f, "<{:#}>", comma_sep(real_params.map(|g| g.print(cx))))
} else {
write!(f, "&lt;{}&gt;", comma_sep(real_params.iter().map(|g| g.print(cx))))
write!(f, "&lt;{}&gt;", comma_sep(real_params.map(|g| g.print(cx))))
}
})
}
Expand Down

0 comments on commit bbbeefd

Please sign in to comment.