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

Implement FromMeta for syn::ExprPath #169

Closed
FlixCoder opened this issue Mar 30, 2022 · 0 comments · Fixed by #170
Closed

Implement FromMeta for syn::ExprPath #169

FlixCoder opened this issue Mar 30, 2022 · 0 comments · Fixed by #170

Comments

@FlixCoder
Copy link

Hi!

Darling allows this nicely:

[derive(Debug, FromField)]
#[darling(attributes(merge))]
struct FieldAttrs {
	#[darling(default)]
	pub custom: Option<syn::Path>,
}

But the same is not possible with ExprPath, as FromMeta is not implemented for it:

[derive(Debug, FromField)]
#[darling(attributes(merge))]
struct FieldAttrs {
	#[darling(default)]
	pub custom: Option<syn::ExprPath>,
}
the trait bound `syn::ExprPath: darling::FromMeta` is not satisfied
required because of the requirements on the impl of `darling::FromMeta` for `std::option::Option<syn::ExprPath>`

Use case: e.g. serde uses ExprPath to specify a function to apply to fields in certain actions (serialize_with). I would like to do something similar. syn::Path does not allow to use generics inside the path.

Is there another way to solve this? Can FromMeta be implemented for it?

TedDriggs added a commit that referenced this issue Mar 30, 2022
TedDriggs added a commit that referenced this issue Mar 30, 2022
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 a pull request may close this issue.

1 participant