Return type of field of property instead of property.

This commit is contained in:
andrew.kraevskii
2026-03-04 01:13:03 +03:00
parent e3a4506194
commit cc10d806fe
7 changed files with 28 additions and 29 deletions

View File

@@ -33,9 +33,9 @@ shape: ShapeKind,
properties: std.ArrayList(Property),
children: std.ArrayList(Object),
pub fn getProperty(self: Object, tag: std.meta.Tag(PropertyData)) ?*const PropertyData {
pub fn getProperty(self: Object, comptime tag: std.meta.Tag(PropertyData)) ?@FieldType(PropertyData, @tagName(tag)) {
for (self.properties.items) |*prop| {
if (std.meta.activeTag(prop.data) == tag) return &prop.data;
if (std.meta.activeTag(prop.data) == tag) return @field(prop.data, @tagName(tag));
}
return null;
}