Skip to content

Commit

Permalink
Allow decode helper to take std.data.json JSON stream.
Browse files Browse the repository at this point in the history
This allows implementation of high-performance custom decoders.
  • Loading branch information
FeepingCreature committed May 21, 2024
1 parent 830b1a6 commit 6110e75
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/text/json/Decode.d
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public template decodeJsonInternal(T, alias transform, Flag!"logErrors" logError
{
return decodeJSONValue(jsonStream, mask);
}
else static if (__traits(compiles, transform!T(jsonStream)))
{
// fast path
return transform!T(jsonStream);
}
else static if (__traits(compiles, isCallable!(transform!T)) && isCallable!(transform!T))
{
static assert(Parameters!(transform!T).length == 1, "`transform` must take one parameter.");
Expand Down

0 comments on commit 6110e75

Please sign in to comment.