Skip to content

Commit e8f5c13

Browse files
committed
Variant: auto infer safe & update type method
1 parent ff90621 commit e8f5c13

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

source/mongoschema/variant.d

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ final struct SchemaVariant(Specs...) if (distinctFieldNames!(Specs))
9494
enum hasType = staticIndexOf!(T, Types) != -1;
9595
}
9696

97-
public @safe:
97+
public:
9898
Algebraic!Types value;
9999

100100
this(T)(T value) @trusted
@@ -122,9 +122,9 @@ public @safe:
122122
if (!value.hasValue)
123123
return null;
124124

125-
static foreach (T; Types)
126-
if (isType!T)
127-
return T.stringof;
125+
static foreach (Field; Fields)
126+
if (isType!(Field.Type))
127+
return Field.name;
128128

129129
assert(false, "Checked all possible types of variant but none of them matched?!");
130130
}

0 commit comments

Comments
 (0)