Skip to content

Commit

Permalink
Clarify that all fields are usable in BinWrite directives
Browse files Browse the repository at this point in the history
Closes #208.
  • Loading branch information
csnover committed Jun 29, 2023
1 parent 207b6c8 commit 021e302
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions binrw/doc/attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ argument of a
<span class="bw">[`BinWrite::write_options`](crate::BinWrite::write_options)</span>
call, respectively.

Any earlier field or [import](#arguments) can be referenced in `args`.
Any <span class="brw">(earlier only, when reading)</span><span class="br">earlier</span>
field or [import](#arguments) can be referenced in `args`.

## Ways to pass and receive arguments

Expand Down Expand Up @@ -429,7 +430,8 @@ executed in order.
Assertions added to the top of an enum will be checked against every variant
in the enum.

Any earlier field or [import](#arguments) can be referenced by expressions
Any <span class="brw">(earlier only, when reading)</span><span class="br">earlier</span>
field or [import](#arguments) can be referenced by expressions
in the directive.

## Examples
Expand Down Expand Up @@ -643,7 +645,9 @@ a struct field:
</div>

The `is_big` and `is_little` directives are primarily useful when byte order
is defined in the data itself. Any earlier field or [import](#arguments) can
is defined in the data itself. Any
<span class="brw">(earlier only, when reading)</span><span class="br">earlier</span>
field or [import](#arguments) can
be referenced in the condition. Conditional byte order directives can only
be used on struct fields.

Expand Down Expand Up @@ -819,8 +823,9 @@ a struct field</span>:
```
</div>

Any <span class="br">earlier</span> field or [import](#arguments) can be
referenced by the expression in the directive.
Any <span class="brw">(earlier only, when reading)</span><span class="br">earlier</span>
field or [import](#arguments) can be referenced by the expression in the
directive.

When using `try_calc`, the produced value must be a [`Result<T, E>`](Result).

Expand Down Expand Up @@ -940,7 +945,8 @@ The alternate expression is not evaluated unless the condition is false, so
it is safe for it to contain expensive operations without impacting
performance.

Any earlier field or [import](#arguments) can be referenced by the
Any <span class="brw">(earlier only, when reading)</span><span class="br">earlier</span>
field or [import](#arguments) can be referenced by the
expression in the directive.

<span class="bw">The [`map`](#map) directive can also be used to conditionally
Expand Down Expand Up @@ -1606,7 +1612,8 @@ and must return a type that implements [`BinWrite`](crate::BinWrite) for
<span class="bw">will receive an immutable reference to the entire object
and must return a type that implements [`BinWrite`](crate::BinWrite).</span>

Any <span class="br">earlier</span> field or [import](#arguments) can be
Any <span class="brw">(earlier only, when reading)</span><span class="br">earlier</span>
field or [import](#arguments) can be
referenced by the expression in the directive.

## Examples
Expand Down Expand Up @@ -1930,7 +1937,8 @@ read the string and `pad_size_to(256)` will ensure the reader skips whatever
padding, if any, remains. If the string is longer than 256 bytes, no padding
will be skipped.

Any <span class="br">earlier</span> field or [import](#arguments) can be
Any <span class="brw">(earlier only, when reading)</span><span class="br">earlier</span>
field or [import](#arguments) can be
referenced by the expressions in any of these directives.

## Examples
Expand Down

0 comments on commit 021e302

Please sign in to comment.