_ => {
return PathParameters::AngleBracketed {
lifetimes: lifetimes,
- types: types.clean(cx)
+ types: types.clean(cx),
+ bindings: vec![]
}
}
};
PathParameters::AngleBracketed {
lifetimes: lifetimes,
types: types.clean(cx),
+ bindings: vec![] // FIXME(#20646)
}
}
}
AngleBracketed {
lifetimes: Vec<Lifetime>,
types: Vec<Type>,
+ bindings: Vec<TypeBinding>
},
Parenthesized {
inputs: Vec<Type>,
ast::AngleBracketedParameters(ref data) => {
PathParameters::AngleBracketed {
lifetimes: data.lifetimes.clean(cx),
- types: data.types.clean(cx)
+ types: data.types.clean(cx),
+ bindings: data.bindings.clean(cx)
}
}
params: PathParameters::AngleBracketed {
lifetimes: vec![],
types: vec![t.clean(cx)],
+ bindings: vec![]
}
}],
},
}
}
+
+/// An equality constraint on an associated type, e.g. `A=Bar` in `Foo<A=Bar>`
+#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable)]
+pub struct TypeBinding {
+ pub name: String,
+ pub ty: Type
+}
+
+impl Clean<TypeBinding> for ast::TypeBinding {
+ fn clean(&self, cx: &DocContext) -> TypeBinding {
+ TypeBinding {
+ name: self.ident.clean(cx),
+ ty: self.ty.clean(cx)
+ }
+ }
+}
impl fmt::String for clean::PathParameters {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
- clean::PathParameters::AngleBracketed { ref lifetimes, ref types } => {
- if lifetimes.len() > 0 || types.len() > 0 {
+ clean::PathParameters::AngleBracketed {
+ ref lifetimes, ref types, ref bindings
+ } => {
+ if lifetimes.len() > 0 || types.len() > 0 || bindings.len() > 0 {
try!(f.write_str("<"));
let mut comma = false;
for lifetime in lifetimes.iter() {
comma = true;
try!(write!(f, "{}", *ty));
}
+ for binding in bindings.iter() {
+ if comma {
+ try!(f.write_str(", "));
+ }
+ comma = true;
+ try!(write!(f, "{}", *binding));
+ }
try!(f.write_str(">"));
}
}
params: clean::PathParameters::AngleBracketed {
lifetimes: Vec::new(),
types: Vec::new(),
+ bindings: Vec::new()
}
})
};
}
}
+//NOTE(stage0): remove impl after snapshot
+impl fmt::Show for clean::TypeBinding {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::String::fmt(self, f)
+ }
+}
+
+impl fmt::String for clean::TypeBinding {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "{}={}", self.name, self.ty)
+ }
+}
+
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for MutableSpace {