@@ -1139,6 +1139,7 @@ fn print_tuple_struct_fields(w: &mut Buffer, cx: &Context<'_>, s: &[clean::Item]
1139
1139
}
1140
1140
1141
1141
fn item_enum ( w : & mut Buffer , cx : & Context < ' _ > , it : & clean:: Item , e : & clean:: Enum ) {
1142
+ let count_variants = e. variants ( ) . count ( ) ;
1142
1143
wrap_into_docblock ( w, |w| {
1143
1144
wrap_item ( w, "enum" , |w| {
1144
1145
render_attributes_in_pre ( w, it, "" ) ;
@@ -1150,16 +1151,16 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
1150
1151
e. generics. print( cx) ,
1151
1152
print_where_clause( & e. generics, cx, 0 , true ) ,
1152
1153
) ;
1153
- if e. variants . is_empty ( ) && !e. variants_stripped {
1154
+ let variants_stripped = e. has_stripped_entries ( ) ;
1155
+ if count_variants == 0 && !variants_stripped {
1154
1156
w. write_str ( " {}" ) ;
1155
1157
} else {
1156
1158
w. write_str ( " {\n " ) ;
1157
- let count_variants = e. variants . len ( ) ;
1158
1159
let toggle = should_hide_fields ( count_variants) ;
1159
1160
if toggle {
1160
1161
toggle_open ( w, format_args ! ( "{} variants" , count_variants) ) ;
1161
1162
}
1162
- for v in & e. variants {
1163
+ for v in e. variants ( ) {
1163
1164
w. write_str ( " " ) ;
1164
1165
let name = v. name . unwrap ( ) ;
1165
1166
match * v. kind {
@@ -1188,7 +1189,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
1188
1189
w. write_str ( ",\n " ) ;
1189
1190
}
1190
1191
1191
- if e . variants_stripped {
1192
+ if variants_stripped {
1192
1193
w. write_str ( " // some variants omitted\n " ) ;
1193
1194
}
1194
1195
if toggle {
@@ -1201,15 +1202,15 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
1201
1202
1202
1203
document ( w, cx, it, None , HeadingOffset :: H2 ) ;
1203
1204
1204
- if !e . variants . is_empty ( ) {
1205
+ if count_variants != 0 {
1205
1206
write ! (
1206
1207
w,
1207
1208
"<h2 id=\" variants\" class=\" variants small-section-header\" >\
1208
1209
Variants{}<a href=\" #variants\" class=\" anchor\" ></a></h2>",
1209
1210
document_non_exhaustive_header( it)
1210
1211
) ;
1211
1212
document_non_exhaustive ( w, it) ;
1212
- for variant in & e. variants {
1213
+ for variant in e. variants ( ) {
1213
1214
let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: Variant , variant. name. unwrap( ) ) ) ;
1214
1215
write ! (
1215
1216
w,
@@ -1653,7 +1654,7 @@ fn render_union(
1653
1654
}
1654
1655
}
1655
1656
1656
- if it. has_stripped_fields ( ) . unwrap ( ) {
1657
+ if it. has_stripped_entries ( ) . unwrap ( ) {
1657
1658
write ! ( w, " /* private fields */\n {}" , tab) ;
1658
1659
}
1659
1660
if toggle {
@@ -1709,11 +1710,11 @@ fn render_struct(
1709
1710
}
1710
1711
1711
1712
if has_visible_fields {
1712
- if it. has_stripped_fields ( ) . unwrap ( ) {
1713
+ if it. has_stripped_entries ( ) . unwrap ( ) {
1713
1714
write ! ( w, "\n {} /* private fields */" , tab) ;
1714
1715
}
1715
1716
write ! ( w, "\n {}" , tab) ;
1716
- } else if it. has_stripped_fields ( ) . unwrap ( ) {
1717
+ } else if it. has_stripped_entries ( ) . unwrap ( ) {
1717
1718
write ! ( w, " /* private fields */ " ) ;
1718
1719
}
1719
1720
if toggle {
0 commit comments