Skip to content

Commit 6d08949

Browse files
committed
Migrate VariantKind construction function to associated function.
1 parent 0d0f1b4 commit 6d08949

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ impl Clean<Item> for doctree::Variant {
20262026
deprecation: self.depr.clean(cx),
20272027
def_id: cx.map.local_def_id(self.def.id()),
20282028
inner: VariantItem(Variant {
2029-
kind: struct_def_to_variant_kind(&self.def, cx),
2029+
kind: VariantKind::from_struct_def(&self.def, cx),
20302030
}),
20312031
}
20322032
}
@@ -2080,13 +2080,15 @@ pub enum VariantKind {
20802080
StructVariant(VariantStruct),
20812081
}
20822082

2083-
fn struct_def_to_variant_kind(struct_def: &hir::VariantData, cx: &DocContext) -> VariantKind {
2084-
if struct_def.is_struct() {
2085-
StructVariant(struct_def.clean(cx))
2086-
} else if struct_def.is_unit() {
2087-
CLikeVariant
2088-
} else {
2089-
TupleVariant(struct_def.fields().iter().map(|x| x.ty.clean(cx)).collect())
2083+
impl VariantKind {
2084+
fn from_struct_def(struct_def: &hir::VariantData, cx: &DocContext) -> VariantKind {
2085+
if struct_def.is_struct() {
2086+
StructVariant(struct_def.clean(cx))
2087+
} else if struct_def.is_unit() {
2088+
CLikeVariant
2089+
} else {
2090+
TupleVariant(struct_def.fields().iter().map(|x| x.ty.clean(cx)).collect())
2091+
}
20902092
}
20912093
}
20922094

0 commit comments

Comments
 (0)