@@ -20,7 +20,7 @@ pub struct Struct<'a> {
20
20
/// Visibility
21
21
pub vis : & ' a ast:: VisibilityKind ,
22
22
pub name : symbol:: Symbol ,
23
- pub fields : Vec < ( & ' a ast:: VisibilityKind , symbol:: Symbol , String ) > ,
23
+ pub fields : Vec < ( & ' a ast:: VisibilityKind , Option < symbol:: Symbol > , String ) > ,
24
24
}
25
25
26
26
impl < ' a > PartialEq for Struct < ' a > {
@@ -58,8 +58,11 @@ impl <'a>From<((&'a ast::Item, &'a Vec<ast::FieldDef>), Rc<ModulePath>)> for Str
58
58
name : item. ident . name ,
59
59
fields : struct_field. iter ( )
60
60
. filter_map ( |& ast:: FieldDef { span : _, ident, ref vis, id : _, ref ty, .. } |
61
- ident. and_then ( |symbol:: Ident { name, ..} | Some ( ( & vis. kind , name, ty_to_string ( & ty) ) ) ) )
62
- . collect :: < Vec < ( & ast:: VisibilityKind , symbol:: Symbol , String ) > > ( )
61
+ match ident {
62
+ Some ( i) => Some ( ( & vis. kind , Some ( i. name ) , ty_to_string ( & ty) ) ) ,
63
+ None => Some ( ( & vis. kind , None , ty_to_string ( & ty) ) ) ,
64
+ } )
65
+ . collect :: < Vec < ( & ast:: VisibilityKind , Option < symbol:: Symbol > , String ) > > ( )
63
66
}
64
67
}
65
68
}
@@ -79,13 +82,17 @@ impl <'a>fmt::Display for Struct<'a> {
79
82
fields_bgcolor = Config :: global( ) . struct_fields_bgcolor,
80
83
name = self . name,
81
84
fields = self . fields. iter( )
82
- . map( |& ( ref vis, ref name, ref ty) : & ( & ast:: VisibilityKind , symbol:: Symbol , String ) |
85
+ . map( |& ( ref vis, ref name, ref ty) : & ( & ast:: VisibilityKind , Option <symbol:: Symbol >, String ) |{
86
+ let name_part = match name {
87
+ Some ( n) => format!( "{}: " , n) ,
88
+ None => "" . to_string( ) ,
89
+ } ;
83
90
escape_html(
84
91
match vis {
85
- ast:: VisibilityKind :: Public => format!( "+ {name}: {ty}" , name = name , ty = ty) ,
86
- _ => format!( "- {name}: {ty}" , name = name , ty = ty)
92
+ ast:: VisibilityKind :: Public => format!( "+ {name}{ty}" , name = name_part , ty = ty) ,
93
+ _ => format!( "- {name}{ty}" , name = name_part , ty = ty)
87
94
} . as_str( ) )
88
- )
95
+ } )
89
96
. collect:: <Vec <String >>( )
90
97
. join( "<br align=\" left\" />\n " )
91
98
. as_str( ) ,
0 commit comments