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 am implementing #[attr(default = <literal>)], and my value can be multi-typed depending on what it gets attached to. The serde_json::Value is the format I will eventually have to work with. Darling seem to have the needed from_value() functions, but I am not too certain how to use it to convert from a syn::Lit into serde_json::Value, possibly via some magical match statement? Thx!
The text was updated successfully, but these errors were encountered:
I'm afraid there's no magical match statement - you'll need to write your own that looks at each Lit variant, gets its value, then uses the .into() conversion for it. How complex that will be depends on how many kinds of JSON value you want to allow, and whether you're going to require it be a literal or would accept any expression that produces impl Into<serde_json::Value>.
@TedDriggs thank you so much for your help! Everything works great, except that it now a required field. Is it possible to have optional expressions, to parse things like #[arg(special)] (no default param)?
I am implementing
#[attr(default = <literal>)]
, and my value can be multi-typed depending on what it gets attached to. Theserde_json::Value
is the format I will eventually have to work with. Darling seem to have the neededfrom_value()
functions, but I am not too certain how to use it to convert from asyn::Lit
intoserde_json::Value
, possibly via some magicalmatch
statement? Thx!The text was updated successfully, but these errors were encountered: