DeriveWhere on packed structs causes `reference to packed field is unaligned` errors.
All of the match statements internally that get references to the fields cause this issue. Currently the std lib detects if the struct is `#[repr(packed)]` and adds implicit `Fields: Copy` bounds to the derive and copies out all the fields instead. Serde does something similar. I think it should be relatively* straightforward to add that in here too. I'd be more than happy to PR that in if its something you would be willing to accept.
*it might actually be a bit more complicated. The self match destructuring might need to be replaced for this. Technically possible to add a Self: Copy bound and still match without the refs, but it wouldn't be optimal.
2 条评论