framesurge / perseus

A state-driven web development framework for Rust with full support for server-side rendering and static generation.
https://framesurge.sh/perseus/en-US
MIT License
2.15k stars 89 forks source link

ReactiveState derive macro panics when used on newtype structs #257

Open godstail opened 1 year ago

godstail commented 1 year ago

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 <>.

Tribble internal data dHJpYmJsZS1yZXBvcnRlZCxDLWJ1Zw==
arctic-hen7 commented 1 year ago

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 commented 1 year ago

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