refactor: simplify switches using inline

This commit is contained in:
Simon Hartcher 2025-06-05 11:05:54 +10:00
parent 90d1091b66
commit d60ce20305

View file

@ -15,36 +15,14 @@ pub fn getShapeInfo(id: []const u8, shapes: std.StringHashMap(smithy.ShapeInfo))
pub fn getShapeTraits(shape: Shape) []smithy.Trait {
return switch (shape) {
.@"enum" => |s| s.traits,
.bigDecimal,
.bigInteger,
.blob,
.boolean,
.byte,
.document,
.double,
.float,
.integer,
.long,
.member,
.short,
.string,
.timestamp,
.unit,
=> |s| s.traits,
.list => |s| s.traits,
.map => |s| s.traits,
.set => |s| s.traits,
.structure => |s| s.traits,
.uniontype => |s| s.traits,
else => std.debug.panic("Unexpected shape type: {}", .{shape}),
.service, .operation, .resource => std.debug.panic("Unexpected shape type: {}", .{shape}),
inline else => |s| s.traits,
};
}
pub fn getShapeMembers(shape: Shape) []smithy.TypeMember {
return switch (shape) {
.structure => |s| s.members,
.uniontype => |s| s.members,
inline .structure, .uniontype => |s| s.members,
else => std.debug.panic("Unexpected shape type: {}", .{shape}),
};
}