sharksforarms / deku

Declarative binary reading and writing: bit-level, symmetric, serialization/deserialization
Apache License 2.0
1.11k stars 54 forks source link

Skip doesn't work #256

Closed mamscience closed 2 years ago

mamscience commented 2 years ago

Hello

Can anyone explain why doesn't this work? (Using latest version of Deku and latest stable version of Rust)

use deku::*;
#[derive(Debug, PartialEq, DekuRead, DekuWrite, Default)]
struct Request2 {
    #[deku(skip, default = "1")]
    id:  i16,
    header:  i16,
}
let xol=  Request2{header: 4};

Error


error[E0063]: missing field `id` in initializer of `Request2`
  --> device/src/lib.rs:91:15
   |
91 |     let xol=  Request2{header2: 4}; 
   |               ^^^^^^^^ missing `id`
mamscience commented 2 years ago

My bad, I misunderstood the function. I solved my issue using the 'derive builder' crate.