}
}
+#[derive(Clone, Copy, PartialEq, Eq)]
+pub(crate) enum Ending {
+ Newline,
+ NoNewline,
+}
+
/// * The Generics from which to emit a where-clause.
/// * The number of spaces to indent each line with.
/// * Whether the where-clause needs to add a comma and newline after the last bound.
gens: &'a clean::Generics,
cx: &'a Context<'tcx>,
indent: usize,
- end_newline: bool,
+ ending: Ending,
) -> impl fmt::Display + 'a + Captures<'tcx> {
use fmt::Write;
let where_preds = comma_sep(where_predicates, false);
let clause = if f.alternate() {
- if end_newline {
+ if ending == Ending::Newline {
// add a space so stripping <br> tags and breaking spaces still renders properly
format!(" where{where_preds}, ")
} else {
}
let where_preds = where_preds.to_string().replace("<br>", &br_with_padding);
- if end_newline {
+ if ending == Ending::Newline {
let mut clause = " ".repeat(indent.saturating_sub(1));
// add a space so stripping <br> tags and breaking spaces still renders properly
write!(
if f != r {
let dissimilar_part_count = relative_to_fqp.len() - i;
let fqp_module = &fqp[i..fqp.len()];
- return box iter::repeat(sym::dotdot)
- .take(dissimilar_part_count)
- .chain(fqp_module.iter().copied());
+ return Box::new(
+ iter::repeat(sym::dotdot)
+ .take(dissimilar_part_count)
+ .chain(fqp_module.iter().copied()),
+ );
}
}
// e.g. linking to std::sync::atomic from std::sync
if relative_to_fqp.len() < fqp.len() {
- box fqp[relative_to_fqp.len()..fqp.len()].iter().copied()
+ Box::new(fqp[relative_to_fqp.len()..fqp.len()].iter().copied())
// e.g. linking to std::sync from std::sync::atomic
} else if fqp.len() < relative_to_fqp.len() {
let dissimilar_part_count = relative_to_fqp.len() - fqp.len();
- box iter::repeat(sym::dotdot).take(dissimilar_part_count)
+ Box::new(iter::repeat(sym::dotdot).take(dissimilar_part_count))
// linking to the same module
} else {
- box iter::empty()
+ Box::new(iter::empty())
}
}
fmt_type(&self.for_, f, use_absolute, cx)?;
}
- fmt::Display::fmt(&print_where_clause(&self.generics, cx, 0, true), f)?;
+ fmt::Display::fmt(&print_where_clause(&self.generics, cx, 0, Ending::Newline), f)?;
Ok(())
})
}