1use crate::ast::NestedMeta;
2use crate::util::PathList;
3use crate::{FromMeta, Result};
4
5/// A rule about which attributes to forward to the generated struct.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum ForwardAttrs {
8 All,
9 Only(PathList),
10}
11
12impl ForwardAttrs {
13 /// Returns `true` if this will not forward any attributes.
14 pub fn is_empty(&self) -> bool {
15 match *self {
16 ForwardAttrs::All => false,
17 ForwardAttrs::Only(ref list: &PathList) => list.is_empty(),
18 }
19 }
20}
21
22impl FromMeta for ForwardAttrs {
23 fn from_word() -> Result<Self> {
24 Ok(ForwardAttrs::All)
25 }
26
27 fn from_list(nested: &[NestedMeta]) -> Result<Self> {
28 Ok(ForwardAttrs::Only(PathList::from_list(items:nested)?))
29 }
30}
31