If an Option<T> is enclosed inside some other type (struct, enum, map, tuple, etc.) and the None variant is present: the element following the decoded None will be read as a nil since the nil-byte is still in the stream.
This is because read_option uses _peek_byte() to determine if a nil value is in the stream but it does not consume that byte if a None was present. Thus when the next token is read from the stream it will be read as a nil.
This can be fixed by simply consuming the nil if we successfully read a None variant.
I added a test and fix on my fork: feature/fix-option-nullary however it will be blocked on PR #39 being merged.
If an
Option<T>
is enclosed inside some other type (struct, enum, map, tuple, etc.) and theNone
variant is present: the element following the decodedNone
will be read as anil
since the nil-byte is still in the stream.This is because
read_option
uses_peek_byte()
to determine if anil
value is in the stream but it does not consume that byte if aNone
was present. Thus when the next token is read from the stream it will be read as anil
.This can be fixed by simply consuming the
nil
if we successfully read aNone
variant. I added a test and fix on my fork: feature/fix-option-nullary however it will be blocked on PR #39 being merged.