You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a struct with a lot of fields (~ 50-ish). The types are mostly a number, a string or a bool. Is there an easier way to declare the default values then using the default attribute? E.g.:
pubstructConfig{#[serde(default = "default_some_field")]some_field:String,// default value is "edged"}fndefault_some_field() -> String{"edged".into()}
I expected the argument to be the default value, e.g. default = "edged" where the proc_macro tries to into() into the type of the field. Maybe the current behaviour could be encoded behind a field called default_fn or something.
P.S.: I am not actually sure if the above proposal is currently possible in syn.
I have a struct with a lot of fields (~ 50-ish). The types are mostly a number, a string or a bool. Is there an easier way to declare the default values then using the
default
attribute? E.g.:I expected the argument to be the default value, e.g.
default = "edged"
where theproc_macro
tries tointo()
into the type of the field. Maybe the current behaviour could be encoded behind a field calleddefault_fn
or something.P.S.: I am not actually sure if the above proposal is currently possible in
syn
.Further examples:
Would all work as expected as the values can properly be converted using
into()
orparse
.Wouldn't work as
seven
can't be parsed correctly into a number.The text was updated successfully, but these errors were encountered: