from_attr/path_value.rs
1use proc_macro2::Span;
2
3use crate::ConvertParsed;
4
5/// Represents the path-value pair parsed from the [`meta`](syn::meta::ParseNestedMeta).
6pub struct PathValue<T> {
7 /// The path of the meta.
8 pub path: Span,
9 /// The value parsed from the meta.
10 pub value: T,
11}
12
13impl<T> ConvertParsed for PathValue<T>
14where
15 T: ConvertParsed,
16{
17 type Type = T::Type;
18
19 fn convert(path_value: PathValue<Self::Type>) -> syn::Result<Self> {
20 Ok(PathValue {
21 path: path_value.path,
22 value: T::convert(path_value)?,
23 })
24 }
25
26 fn flag() -> Option<Self::Type> {
27 T::flag()
28 }
29}