Skip to content

How are optional values supposed to work? #278

Answered by ckrenslehner
krakow10 asked this question in Q&A
Discussion options

You must be logged in to vote

https://docs.rs/binrw/latest/binrw/docs/attribute/index.html#conditional-values

I think you always need to link the Option to a condition based on a previosly parsed field. How else would it be possible to decide if it is okay, that there is no value or simply a parsing error?

In reality you would most likely use a separate field with either a version or lenght to decide how many bytes you need to parse

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@krakow10
Comment options

@csnover
Comment options

@krakow10
Comment options

Answer selected by krakow10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #277 on July 28, 2024 18:37.