Refactor ast::GenericParam as a struct
This commit is contained in:
@@ -2878,12 +2878,24 @@ impl<'a> State<'a> {
|
||||
self.s.word("<")?;
|
||||
|
||||
self.commasep(Inconsistent, &generic_params, |s, param| {
|
||||
match *param {
|
||||
ast::GenericParamAST::Lifetime(ref lifetime_def) => {
|
||||
s.print_outer_attributes_inline(&lifetime_def.attrs)?;
|
||||
s.print_lifetime_bounds(&lifetime_def.lifetime, &lifetime_def.bounds)
|
||||
match param.kind {
|
||||
ast::GenericParamKindAST::Lifetime { ref bounds, ref lifetime } => {
|
||||
s.print_outer_attributes_inline(¶m.attrs)?;
|
||||
s.print_lifetime_bounds(lifetime, bounds)
|
||||
},
|
||||
ast::GenericParamAST::Type(ref ty_param) => s.print_ty_param(ty_param),
|
||||
ast::GenericParamKindAST::Type { ref bounds, ref default } => {
|
||||
s.print_outer_attributes_inline(¶m.attrs)?;
|
||||
s.print_ident(param.ident)?;
|
||||
s.print_bounds(":", bounds)?;
|
||||
match default {
|
||||
Some(ref default) => {
|
||||
s.s.space()?;
|
||||
s.word_space("=")?;
|
||||
s.print_type(default)
|
||||
}
|
||||
_ => Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
||||
@@ -2891,20 +2903,6 @@ impl<'a> State<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn print_ty_param(&mut self, param: &ast::TyParam) -> io::Result<()> {
|
||||
self.print_outer_attributes_inline(¶m.attrs)?;
|
||||
self.print_ident(param.ident)?;
|
||||
self.print_bounds(":", ¶m.bounds)?;
|
||||
match param.default {
|
||||
Some(ref default) => {
|
||||
self.s.space()?;
|
||||
self.word_space("=")?;
|
||||
self.print_type(default)
|
||||
}
|
||||
_ => Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_where_clause(&mut self, where_clause: &ast::WhereClause)
|
||||
-> io::Result<()> {
|
||||
if where_clause.predicates.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user