1 use syn::Attribute;
2 
3 use crate::Result;
4 
5 /// Create an instance by parsing a list of attributes.
6 ///
7 /// This trait is useful when dealing with items such as traits on traits and impl blocks,
8 /// for which `darling` does not provide dedicated traits.
9 pub trait FromAttributes: Sized {
10     /// Create an instance by parsing a list of attributes.
11     ///
12     /// By convention, `FromAttributes` implementations should merge item
13     /// declarations across attributes, so that the following forms are
14     /// equivalent:
15     ///
16     /// ```rust,ignore
17     /// #[derive(Serialize)]
18     /// #[serde(rename_all = "camel_case")]
19     /// #[serde(borrow)]
20     /// pub struct SplitExample {}
21     ///
22     /// #[derive(Serialize)]
23     /// #[serde(borrow, rename_all = "camel_case")]
24     /// pub struct JoinedExample {}
25     /// ```
from_attributes(attrs: &[Attribute]) -> Result<Self>26     fn from_attributes(attrs: &[Attribute]) -> Result<Self>;
27 }
28