Skip to content

Commit f26d57d

Browse files
committed
ir: Use early return in c_naming_prefix.
1 parent 4943058 commit f26d57d

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/ir/item.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,18 +1063,19 @@ impl Item {
10631063

10641064
/// Returns a prefix for the canonical name when C naming is enabled.
10651065
fn c_naming_prefix(&self) -> Option<&str> {
1066-
if let ItemKind::Type(typ) = &self.kind {
1067-
match typ.kind() {
1068-
TypeKind::Comp(comp_info) => match comp_info.kind() {
1069-
CompKind::Struct => Some("struct"),
1070-
CompKind::Union => Some("union"),
1071-
},
1072-
TypeKind::Enum(_) => Some("enum"),
1073-
_ => None,
1074-
}
1075-
} else {
1076-
None
1077-
}
1066+
let ty = match self.kind {
1067+
ItemKind::Type(ref ty) => ty,
1068+
_ => return None,
1069+
};
1070+
1071+
Some(match ty.kind() {
1072+
TypeKind::Comp(ref ci) => match ci.kind() {
1073+
CompKind::Struct => "struct",
1074+
CompKind::Union => "union",
1075+
},
1076+
TypeKind::Enum(..) => "enum",
1077+
_ => return None,
1078+
})
10781079
}
10791080
}
10801081

0 commit comments

Comments
 (0)