Skip to content

Commit

Permalink
fix docs: type->id_type (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal-So authored Nov 16, 2024
1 parent 2b24a56 commit 704f7c7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deku-derive/src/macros/deku_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ fn emit_enum(input: &DekuData) -> Result<TokenStream, syn::Error> {
let __deku_variant_id = <#id_type>::from_reader_with_ctx(__deku_reader, (#id_args))?;
}
} else {
// either `id` or `type` needs to be specified
// either `id` or `id_type` needs to be specified
unreachable!();
};

Expand Down
2 changes: 1 addition & 1 deletion deku-derive/src/macros/deku_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ fn emit_enum(input: &DekuData) -> Result<TokenStream, syn::Error> {
));
}
} else {
// either `id` or `type` needs to be specified
// either `id` or `id_type` needs to be specified
unreachable!();
};

Expand Down
6 changes: 3 additions & 3 deletions src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ enum DekuEnum {
| enum: [id](#id) | top-level, variant | enum or variant id value
| enum: [id_endian](#id_endian) | top-level | Endianness of *just* the enum `id`
| enum: [id_pat](#id_pat) | variant | variant id match pattern
| enum: [type](#type) | top-level | Set the type of the variant `id`
| enum: [id_type](#id_type) | top-level | Set the type of the variant `id`
| enum: [bits](#bits-1) | top-level | Set the bit-size of the variant `id`
| enum: [bytes](#bytes-1) | top-level | Set the byte-size of the variant `id`
Expand Down Expand Up @@ -1362,7 +1362,7 @@ assert_eq!(&*ret_write, data)
## id (variant)
Specify the identifier of the enum variant, must be paired with [type](#type)
Specify the identifier of the enum variant, must be paired with [id_type](#id_type)
or [id (top-level)](#id-top-level)
**Note**:
Expand Down Expand Up @@ -1533,7 +1533,7 @@ let variant_bytes: Vec<u8> = value.try_into().unwrap();
assert_eq!(vec![0xFF], variant_bytes);
```
# type
# id_type
Specify the type of the enum variant id to consume, see [example](#id-variant)
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ assert_eq!(DekuTest {
As enums can have multiple variants, each variant must have a way to match on
the incoming data.
First the "type" is read using the `type`, then is matched against the
First the "type" is read using `id_type`, then is matched against the
variants given `id`. What happens after is the same as structs!
This is implemented with the [id](attributes#id),
[id_pat](attributes#id_pat), [default](attributes#default) and
[type](attributes#type) attributes. See these for more examples.
[id_type](attributes#id_type) attributes. See these for more examples.
If no `id` is specified, the variant will default to it's discriminant value.
Expand Down

0 comments on commit 704f7c7

Please sign in to comment.