Changes

342 bytes added ,  00:09, 6 January 2021
Corrected valid arguments for pair codecs
Line 141: Line 141:  
The <code>Codec.pair(codecA, codecB)</code> static method takes two codecs and generates a Codec<Pair<A,B>> from them.
 
The <code>Codec.pair(codecA, codecB)</code> static method takes two codecs and generates a Codec<Pair<A,B>> from them.
   −
Using this function requires that codecA be a codec that serializes to a string.
+
The only valid arguments for this method are codecs that serialize to objects, such as codecs created using [[Codecs#Records|RecordCodecBuilder]], [[Codecs#Maps|unboundedMap]], or fieldOf. Codecs that serialize nothing (such as [[Codecs#Unit|unit codecs]]) are also valid as they act as objects-with-no-fields.
 +
 
 +
The resulting Pair codec will serialize a single object that has all of the fields of the two original codecs.
    
==Either==
 
==Either==
22

edits