refactor: simplify switches using inline
This commit is contained in:
parent
90d1091b66
commit
d60ce20305
1 changed files with 3 additions and 25 deletions
|
@ -15,36 +15,14 @@ pub fn getShapeInfo(id: []const u8, shapes: std.StringHashMap(smithy.ShapeInfo))
|
||||||
|
|
||||||
pub fn getShapeTraits(shape: Shape) []smithy.Trait {
|
pub fn getShapeTraits(shape: Shape) []smithy.Trait {
|
||||||
return switch (shape) {
|
return switch (shape) {
|
||||||
.@"enum" => |s| s.traits,
|
.service, .operation, .resource => std.debug.panic("Unexpected shape type: {}", .{shape}),
|
||||||
.bigDecimal,
|
inline else => |s| s.traits,
|
||||||
.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}),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getShapeMembers(shape: Shape) []smithy.TypeMember {
|
pub fn getShapeMembers(shape: Shape) []smithy.TypeMember {
|
||||||
return switch (shape) {
|
return switch (shape) {
|
||||||
.structure => |s| s.members,
|
inline .structure, .uniontype => |s| s.members,
|
||||||
.uniontype => |s| s.members,
|
|
||||||
else => std.debug.panic("Unexpected shape type: {}", .{shape}),
|
else => std.debug.panic("Unexpected shape type: {}", .{shape}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue