jam1garner / binrw

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

Implement BinWrite for PosValue #270

Open amirbou opened 3 months ago

amirbou commented 3 months ago

Hey, currently PosValue does not implement BinWrite, which prevents it from being used in structs using #[binrw].

On my machine I implemented (for PosValue<T>):

I added some asserts in pos_value.rs to check everything, and it seems to be working correctly.

May I go ahead and open a PR with the changes?

Thanks!

csnover commented 3 months ago

Hi, thanks for your report! Implementing BinWrite for PosValue<T> seems reasonable to me since this is just a wrapper type for position metadata. I feel less certain about adding From<T> and Default implementations but can’t think of anything off the top of my head that would be hurt by it. Go ahead and open a PR any time!