Closed wcampbell0x2a closed 2 months ago
This should work:
use deku::prelude::*; #[derive(DekuRead, DekuWrite, Debug)] pub struct A { bit: bool, #[deku(ctx = "*bit")] var: Var, } #[derive(DekuRead, DekuWrite, Debug)] #[deku(id = "bit", ctx = "bit: bool")] pub enum Var { #[deku(id = false)] False(u8), #[deku(id = true)] True(u32), }
It doens't:
error: Unexpected type `bool` --> src/lib.rs:13:17 | 13 | #[deku(id = false)] | ^^^^^ error: Unexpected type `bool` --> src/lib.rs:15:17 | 15 | #[deku(id = true)] | ^^^^
Instead, you need to make the id a TokenStream:
id
use deku::prelude::*; #[derive(DekuRead, DekuWrite, Debug)] pub struct A { bit: bool, #[deku(ctx = "*bit")] var: Var, } #[derive(DekuRead, DekuWrite, Debug)] #[deku(id = "bit", ctx = "bit: bool")] pub enum Var { #[deku(id = "false")] False(u8), #[deku(id = "true")] True(u32), }
This should work:
It doens't:
Instead, you need to make the
id
a TokenStream: