Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add explicit implementations of FromMeta methods to SpannedValue and Override #326

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Lucretiel
Copy link

@Lucretiel Lucretiel commented Feb 19, 2025

Currently, SpannedValue and Override implement only the top-level methods. This means that, if the "low-level" methods like from_string are called, instead of the mid- or -top level methods like from_value or from_meta, the default behavior (an error) will be used. This was leading to errors with this structure:

#[derive(darling::FromAttributes, Debug)]
#[darling(attributes(foo))]
struct RawParsedAttr {
    long: Option<Override<SpannedValue<String>>>,
    short: Option<Override<SpannedValue<char>>>,
}

When parsed from #[foo(long="bar")], this returns an "unexpected type string", because these types end up calling SpannedValue::from_value directly, causing the default behavior (an error) instead of forwarding to String::from_value.

Added some regression tests for this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant