path: Path::new(vec!("std", "marker", name)),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
- methods: vec!()
+ methods: Vec::new(),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
cs_clone("Clone", c, s, sub)
}),
}
- )
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
methods: vec!(
md!("eq", cs_eq),
md!("ne", cs_ne)
- )
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
}
md!("le", true, true),
md!("gt", false, false),
md!("ge", false, true)
- ]
+ ],
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
}
cs_total_eq_assert(a, b, c)
})
}
- )
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
}
cs_cmp(a, b, c)
}),
}
- )
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
combine_substructure: combine_substructure(box |a, b, c| {
decodable_substructure(a, b, c, krate)
}),
- })
+ }
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
combine_substructure: combine_substructure(box |a, b, c| {
default_substructure(a, b, c)
})
- })
+ }
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
}
combine_substructure: combine_substructure(box |a, b, c| {
encodable_substructure(a, b, c)
}),
- })
+ }
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
pub generics: LifetimeBounds<'a>,
pub methods: Vec<MethodDef<'a>>,
+
+ pub associated_types: Vec<(ast::Ident, Ty<'a>)>,
}
methods: Vec<P<ast::Method>>) -> P<ast::Item> {
let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
+ // Transform associated types from `deriving::ty::Ty` into `ast::Typedef`
+ let associated_types = self.associated_types.iter().map(|&(ident, ref type_def)| {
+ P(ast::Typedef {
+ id: ast::DUMMY_NODE_ID,
+ span: self.span,
+ ident: ident,
+ vis: ast::Inherited,
+ attrs: Vec::new(),
+ typ: type_def.to_ty(cx,
+ self.span,
+ type_ident,
+ generics
+ ),
+ })
+ });
+
let Generics { mut lifetimes, ty_params, mut where_clause } =
self.generics.to_generics(cx, self.span, type_ident, generics);
let mut ty_params = ty_params.into_vec();
methods.into_iter()
.map(|method| {
ast::MethodImplItem(method)
- }).collect()))
+ }).chain(
+ associated_types.map(|type_| {
+ ast::TypeImplItem(type_)
+ })
+ ).collect()))
}
fn expand_struct_def(&self,
hash_substructure(a, b, c)
})
}
- )
+ ),
+ associated_types: Vec::new(),
};
hash_trait_def.expand(cx, mitem, item, push);
combine_substructure: combine_substructure(box |c, s, sub| {
cs_from("u64", c, s, sub)
}),
- })
+ }
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
rand_substructure(a, b, c)
})
}
- )
+ ),
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
}
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "fmt", "Debug")),
+ path: Path::new(vec!["std", "fmt", "Debug"]),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
- methods: vec!(
+ methods: vec![
MethodDef {
name: "fmt",
generics: LifetimeBounds::empty(),
show_substructure(a, b, c)
})
}
- )
+ ],
+ associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
}