lesurp / OptionalStruct

Macro copying a struct with Option fields. Useful for config initialization
Apache License 2.0
36 stars 12 forks source link

Can't use with other derive attributes #8

Closed norcalli closed 5 years ago

norcalli commented 5 years ago

The parser panic!s incorrectly when it encounters attributes that it doesn't recognize, but this isn't correct since those attributes could belong to other derive macros, like serde.

#[derive(Serialize, Deserialize, OptionalStruct)]
#[serde(rename_all = "camelCase")]
#[optional_name = "PartialChatState"]
#[optional_derive(Serialize, Deserialize)]
struct ChatState {
    messages: Vec<ChatMessage>,
    visitor_name: String,
}

Output

error: proc-macro derive panicked
  --> src/main.rs:68:10
   |
68 | #[derive(OptionalStruct)]
   |          ^^^^^^^^^^^^^^
   |
   = help: message: Only optional_derive are supported

error: aborting due to previous error
detly commented 3 years ago

Did this ever make it into a release?

doivosevic commented 2 years ago

can we somehow make this work with serde? I really need some features like deny_unknown_fields @lesurp

august 2018. is last version change if im correct