jam1garner / binrw

A Rust crate for helping parse and rebuild binary data using ✨macro magic✨.
https://binrw.rs
MIT License
545 stars 35 forks source link

`self` inaccessible in top-level `bw` directive due to keyword rewriting #232

Closed csnover closed 8 months ago

csnover commented 8 months ago

From https://github.com/jam1garner/binrw/discussions/231

The following was working in version 0.11.2:

use binrw::binrw;

#[binrw]
#[bw(assert(self.0 > 0))]
pub struct u24(pub u32);

But fails in version 0.12.0 with:

error[E0425]: cannot find value `__binrw_this` in this scope
 --> src/main.rs:4:13
  |
4 | #[bw(assert(self.0 > 0))]
  |             ^^^^ not found in this scope