avoid `XDeclaredButNotUsed` when no field `isnot JsonVoid` (#87)
Move the type definitions for `Writer` and `Flavor` closer to their usage to avoid verbose hints when they are never used in an invocation.
This commit is contained in:
parent
c869dae884
commit
56c788bb25
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue