@@ -937,6 +937,19 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
937
937
document_type_layout ( w, cx, def_id) ;
938
938
}
939
939
940
+ fn print_tuple_struct_fields ( w : & mut Buffer , cx : & Context < ' _ > , s : & [ clean:: Item ] ) {
941
+ for ( i, ty) in s
942
+ . iter ( )
943
+ . map ( |f| if let clean:: StructFieldItem ( ref ty) = * f. kind { ty } else { unreachable ! ( ) } )
944
+ . enumerate ( )
945
+ {
946
+ if i > 0 {
947
+ w. write_str ( ", " ) ;
948
+ }
949
+ write ! ( w, "{}" , ty. print( cx) ) ;
950
+ }
951
+ }
952
+
940
953
fn item_enum ( w : & mut Buffer , cx : & Context < ' _ > , it : & clean:: Item , e : & clean:: Enum ) {
941
954
wrap_into_docblock ( w, |w| {
942
955
wrap_item ( w, "enum" , |w| {
@@ -964,14 +977,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
964
977
match * v. kind {
965
978
clean:: VariantItem ( ref var) => match var {
966
979
clean:: Variant :: CLike => write ! ( w, "{}" , name) ,
967
- clean:: Variant :: Tuple ( ref tys ) => {
980
+ clean:: Variant :: Tuple ( ref s ) => {
968
981
write ! ( w, "{}(" , name) ;
969
- for ( i, ty) in tys. iter ( ) . enumerate ( ) {
970
- if i > 0 {
971
- w. write_str ( ", " )
972
- }
973
- write ! ( w, "{}" , ty. print( cx) ) ;
974
- }
982
+ print_tuple_struct_fields ( w, cx, s) ;
975
983
w. write_str ( ")" ) ;
976
984
}
977
985
clean:: Variant :: Struct ( ref s) => {
@@ -1024,14 +1032,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
1024
1032
id = id,
1025
1033
name = variant. name. as_ref( ) . unwrap( )
1026
1034
) ;
1027
- if let clean:: VariantItem ( clean:: Variant :: Tuple ( ref tys ) ) = * variant. kind {
1035
+ if let clean:: VariantItem ( clean:: Variant :: Tuple ( ref s ) ) = * variant. kind {
1028
1036
w. write_str ( "(" ) ;
1029
- for ( i, ty) in tys. iter ( ) . enumerate ( ) {
1030
- if i > 0 {
1031
- w. write_str ( ", " ) ;
1032
- }
1033
- write ! ( w, "{}" , ty. print( cx) ) ;
1034
- }
1037
+ print_tuple_struct_fields ( w, cx, s) ;
1035
1038
w. write_str ( ")" ) ;
1036
1039
}
1037
1040
w. write_str ( "</code>" ) ;
@@ -1041,7 +1044,11 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
1041
1044
document_non_exhaustive ( w, variant) ;
1042
1045
1043
1046
use crate :: clean:: Variant ;
1044
- if let clean:: VariantItem ( Variant :: Struct ( ref s) ) = * variant. kind {
1047
+ if let Some ( ( extra, fields) ) = match * variant. kind {
1048
+ clean:: VariantItem ( Variant :: Struct ( ref s) ) => Some ( ( "" , & s. fields ) ) ,
1049
+ clean:: VariantItem ( Variant :: Tuple ( ref fields) ) => Some ( ( "Tuple " , fields) ) ,
1050
+ _ => None ,
1051
+ } {
1045
1052
let variant_id = cx. derive_id ( format ! (
1046
1053
"{}.{}.fields" ,
1047
1054
ItemType :: Variant ,
@@ -1051,10 +1058,10 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
1051
1058
write ! (
1052
1059
w,
1053
1060
"<h3>{extra}Fields of <b>{name}</b></h3><div>" ,
1054
- extra = if s . struct_type == CtorKind :: Fn { "Tuple " } else { "" } ,
1061
+ extra = extra ,
1055
1062
name = variant. name. as_ref( ) . unwrap( ) ,
1056
1063
) ;
1057
- for field in & s . fields {
1064
+ for field in fields {
1058
1065
use crate :: clean:: StructFieldItem ;
1059
1066
if let StructFieldItem ( ref ty) = * field. kind {
1060
1067
let id = cx. derive_id ( format ! (
0 commit comments