Skip to content

Commit

Permalink
Variant: auto infer safe & update type method
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Jan 15, 2019
1 parent ff90621 commit e8f5c13
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/mongoschema/variant.d
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ final struct SchemaVariant(Specs...) if (distinctFieldNames!(Specs))
enum hasType = staticIndexOf!(T, Types) != -1;
}

public @safe:
public:
Algebraic!Types value;

this(T)(T value) @trusted
Expand Down Expand Up @@ -122,9 +122,9 @@ public @safe:
if (!value.hasValue)
return null;

static foreach (T; Types)
if (isType!T)
return T.stringof;
static foreach (Field; Fields)
if (isType!(Field.Type))
return Field.name;

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

0 comments on commit e8f5c13

Please sign in to comment.