Remove unneeded call to collect

This commit is contained in:
Roc Yu 2021-12-25 21:35:05 -05:00
parent 83bde52116
commit bbbeefd860
No known key found for this signature in database
GPG key ID: 5068CE514A79D27F

View file

@ -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))))
}
})
}