Skip to content

Commit

Permalink
avoid XDeclaredButNotUsed when no field isnot JsonVoid (#87)
Browse files Browse the repository at this point in the history
Move the type definitions for `Writer` and `Flavor` closer to their
usage to avoid verbose hints when they are never used in an invocation.
  • Loading branch information
etan-status authored Feb 28, 2024
1 parent c869dae commit 56c788b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions json_serialization/writer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,13 @@ proc writeRecordValue*(w: var JsonWriter, value: auto)
mixin enumInstanceSerializedFields, writeObjectField
mixin flavorOmitsOptionalFields, shouldWriteObjectField

type
Writer = typeof w
Flavor = Writer.Flavor

type RecordType = type value
w.beginRecord RecordType
value.enumInstanceSerializedFields(fieldName, fieldValue):
when fieldValue isnot JsonVoid:
type
Writer = typeof w
Flavor = Writer.Flavor
when flavorOmitsOptionalFields(Flavor):
if shouldWriteObjectField(fieldValue):
writeObjectField(w, value, fieldName, fieldValue)
Expand Down

0 comments on commit 56c788b

Please sign in to comment.