Skip to content
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

#[rlp(..)] does not allow multiple attributes #9

Open
Wodann opened this issue Dec 16, 2023 · 0 comments
Open

#[rlp(..)] does not allow multiple attributes #9

Wodann opened this issue Dec 16, 2023 · 0 comments

Comments

@Wodann
Copy link

Wodann commented Dec 16, 2023

If you want to derive both RlpDecodable and RlpEncodable for a struct that has a field that needs to be omitted, it requires both the #[rlp(default)] (for decoding) and #[rlp(skip) (for encoding) attributes.

However, if you combine these two values into a single field annotation, the procedural macro is no longer able to detect the attributes correctly and raises an error. For example:

struct Foo {
  pub bar: u64,
  #[rlp(default, skip)]
  pub cache: OnceLock<u64>,
}

raises the compiler error the trait bound std::sync::OnceLock: access_list::_::alloy_rlp::Decodable is not satisfied.

Instead writing:

struct Foo {
  pub bar: u64,
  #[rlp(default)]
  #[rlp(skip)]
  pub cache: OnceLock<u64>,
}

does compile successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant