-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add compile-time error when using brw on if
attribute
#148
Comments
The problem alluded to by this ticket exists for any rw directive that accesses fields because read fields are by-value whereas write fields are by-reference. It is actually fine to have |
There are also ways to make it work by using auto(de)ref. Take this example: #[binrw]
struct Test {
#[brw(assert(field.ne(&0u8)))]
field: u8,
} by writing the condition as |
Is there a way to handle this in the general case (ab)using auto-deref so users don’t have to, or is this just some thing that should be documented? |
Unsure. For operators we might be able to get something to work by parsing and replacing uses of operators with uses of traits. This strikes me as error-prone, though. I'd probably just go ahead and document it. |
No description provided.
The text was updated successfully, but these errors were encountered: