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 ForwardAttrsFilter {
8 All,
9 Only(PathList),
10}
11
12impl ForwardAttrsFilter {
13 /// Returns `true` if this will not forward any attributes.
14 pub fn is_empty(&self) -> bool {
15 match *self {
16 ForwardAttrsFilter::All => false,
17 ForwardAttrsFilter::Only(ref list: &PathList) => list.is_empty(),
18 }
19 }
20}
21
22impl FromMeta for ForwardAttrsFilter {
23 fn from_word() -> Result<Self> {
24 Ok(ForwardAttrsFilter::All)
25 }
26
27 fn from_list(nested: &[NestedMeta]) -> Result<Self> {
28 Ok(ForwardAttrsFilter::Only(PathList::from_list(items:nested)?))
29 }
30}
31