From bbbeefd860079d55d5ed23040c6fe081c292e298 Mon Sep 17 00:00:00 2001 From: Roc Yu Date: Sat, 25 Dec 2021 21:35:05 -0500 Subject: [PATCH] Remove unneeded call to `collect` --- src/librustdoc/html/format.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 3a2effa625cf3..d446626cb0656 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -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::>(); - 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, "<{}>", comma_sep(real_params.iter().map(|g| g.print(cx)))) + write!(f, "<{}>", comma_sep(real_params.map(|g| g.print(cx)))) } }) }