Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ReactiveState derive macro panics when used on newtype structs #257

Open
godstail opened this issue Feb 14, 2023 · 2 comments
Open

ReactiveState derive macro panics when used on newtype structs #257

godstail opened this issue Feb 14, 2023 · 2 comments
Labels
C-bug Category: bug tribble-reported This issue was reported through Tribble.

Comments

@godstail
Copy link

This issue is reporting a bug in the code of Perseus. Details of the scope will be available in issue labels.
The author described their issue as follows:

ReactiveState derive macro panics when used on newtype structs:
proc-macro derive panicked
message: called Option::unwrap() on a None value

The steps to reproduce this issue are as follows:

#[derive(Clone, Serialize, Deserialize, ReactiveState)]
pub struct NewType(String);

A minimum reproducible example is available at <>.

  • Hydration-related: false
  • The author is willing to attempt a fix: false
Tribble internal data

dHJpYmJsZS1yZXBvcnRlZCxDLWJ1Zw==

@github-actions github-actions bot added C-bug Category: bug tribble-reported This issue was reported through Tribble. labels Feb 14, 2023
@arctic-hen7
Copy link
Member

This is intended behavior, but there should be a cleaner error. Unit structs and enums are currently not supported by the macro, but implementing reactive state manually is usually not too tricky (and all documented). In your case, I would recommend moving the type into a field so you can use the macro as usual.

@arctic-hen7
Copy link
Member

The ReactiveState macro will be expanded further after v0.4.0 goes stable I think.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: bug tribble-reported This issue was reported through Tribble.
Projects
None yet
Development

No branches or pull requests

2 participants