@@ -20,7 +20,7 @@ pub struct Struct<'a> {
2020 /// Visibility
2121 pub vis : & ' a ast:: VisibilityKind ,
2222 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 ) > ,
2424}
2525
2626impl < ' a > PartialEq for Struct < ' a > {
@@ -58,8 +58,11 @@ impl <'a>From<((&'a ast::Item, &'a Vec<ast::FieldDef>), Rc<ModulePath>)> for Str
5858 name : item. ident . name ,
5959 fields : struct_field. iter ( )
6060 . 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 ) > > ( )
6366 }
6467 }
6568}
@@ -79,13 +82,17 @@ impl <'a>fmt::Display for Struct<'a> {
7982 fields_bgcolor = Config :: global( ) . struct_fields_bgcolor,
8083 name = self . name,
8184 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+ } ;
8390 escape_html(
8491 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)
8794 } . as_str( ) )
88- )
95+ } )
8996 . collect:: <Vec <String >>( )
9097 . join( "<br align=\" left\" />\n " )
9198 . as_str( ) ,
0 commit comments