/// Wrapper struct for emitting a comma-separated list of items
pub struct CommaSep<'a, T>(pub &'a [T]);
pub struct AbiSpace(pub Abi);
+pub struct DefaultSpace(pub bool);
/// Wrapper struct for properly emitting a function or method declaration.
pub struct Function<'a> {
}
}
+impl fmt::Display for clean::Constant {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ fmt::Display::fmt(&self.expr, f)
+ }
+}
+
impl fmt::Display for clean::PolyTrait {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if !self.generic_params.is_empty() {
impl fmt::Display for clean::GenericArgs {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
- clean::GenericArgs::AngleBracketed {
- ref lifetimes, ref types, ref bindings
- } => {
- if !lifetimes.is_empty() || !types.is_empty() || !bindings.is_empty() {
+ clean::GenericArgs::AngleBracketed { ref args, ref bindings } => {
+ if !args.is_empty() || !bindings.is_empty() {
if f.alternate() {
f.write_str("<")?;
} else {
f.write_str("<")?;
}
let mut comma = false;
- for lifetime in lifetimes {
- if comma {
- f.write_str(", ")?;
- }
- comma = true;
- write!(f, "{}", *lifetime)?;
- }
- for ty in types {
+ for arg in args {
if comma {
f.write_str(", ")?;
}
comma = true;
if f.alternate() {
- write!(f, "{:#}", *ty)?;
+ write!(f, "{:#}", *arg)?;
} else {
- write!(f, "{}", *ty)?;
+ write!(f, "{}", *arg)?;
}
}
for binding in bindings {
/// Helper to render type parameters
fn tybounds(w: &mut fmt::Formatter<'_>,
- typarams: &Option<Vec<clean::GenericBound>>) -> fmt::Result {
- match *typarams {
+ param_names: &Option<Vec<clean::GenericBound>>) -> fmt::Result {
+ match *param_names {
Some(ref params) => {
for param in params {
write!(w, " + ")?;
clean::Generic(ref name) => {
f.write_str(name)
}
- clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
- if typarams.is_some() {
+ clean::ResolvedPath{ did, ref param_names, ref path, is_generic } => {
+ if param_names.is_some() {
f.write_str("dyn ")?;
}
// Paths like T::Output and Self::Output should be rendered with all segments
resolved_path(f, did, path, is_generic, use_absolute)?;
- tybounds(f, typarams)
+ tybounds(f, param_names)
}
clean::Infer => write!(f, "_"),
clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()),
}
}
}
- clean::ResolvedPath { typarams: Some(ref v), .. } if !v.is_empty() => {
+ clean::ResolvedPath { param_names: Some(ref v), .. } if !v.is_empty() => {
write!(f, "{}{}{}(", amp, lt, m)?;
fmt_type(&ty, f, use_absolute)?;
write!(f, ")")
// the ugliness comes from inlining across crates where
// everything comes in as a fully resolved QPath (hard to
// look at).
- box clean::ResolvedPath { did, ref typarams, .. } => {
+ box clean::ResolvedPath { did, ref param_names, .. } => {
match href(did) {
Some((ref url, _, ref path)) if !f.alternate() => {
write!(f,
"<a class=\"type\" href=\"{url}#{shortty}.{name}\" \
title=\"type {path}::{name}\">{name}</a>",
url = url,
- shortty = ItemType::AssociatedType,
+ shortty = ItemType::AssocType,
name = name,
path = path.join("::"))?;
}
_ => write!(f, "{}", name)?,
}
- // FIXME: `typarams` are not rendered, and this seems bad?
- drop(typarams);
+ // FIXME: `param_names` are not rendered, and this seems bad?
+ drop(param_names);
Ok(())
}
_ => {
fmt::Display::fmt(ty, f)?;
} else {
match *ty {
- clean::ResolvedPath { typarams: None, ref path, is_generic: false, .. } => {
+ clean::ResolvedPath { param_names: None, ref path, is_generic: false, .. } => {
let last = path.segments.last().unwrap();
fmt::Display::fmt(&last.name, f)?;
fmt::Display::fmt(&last.args, f)?;
}
}
}
+
+impl fmt::Display for DefaultSpace {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ if self.0 {
+ write!(f, "default ")
+ } else {
+ Ok(())
+ }
+ }
+}