1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use proc_macro2::Span;

use crate::ConvertParsed;

/// Represents the path-value pair parsed from the [`meta`](syn::meta::ParseNestedMeta).
pub struct PathValue<T> {
    /// The path of the meta.
    pub path: Span,
    /// The value parsed from the meta.
    pub value: T,
}

impl<T> ConvertParsed for PathValue<T>
where
    T: ConvertParsed,
{
    type Type = T::Type;

    fn convert(path_value: PathValue<Self::Type>) -> syn::Result<Self> {
        Ok(PathValue {
            path: path_value.path,
            value: T::convert(path_value)?,
        })
    }

    fn flag() -> Option<Self::Type> {
        T::flag()
    }
}