display_fn(move |f| {
let mut bounds_dup = FxHashSet::default();
- for (i, bound) in
- bounds.iter().filter(|b| bounds_dup.insert(b.print(cx).to_string())).enumerate()
- {
+ for (i, bound) in bounds.iter().filter(|b| bounds_dup.insert(b.clone())).enumerate() {
if i > 0 {
f.write_str(" + ")?;
}
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, "<{}>", comma_sep(real_params.iter().map(|g| g.print(cx))))
+ write!(f, "<{}>", comma_sep(real_params.map(|g| g.print(cx))))
}
})
}