summaryrefslogtreecommitdiffstats
path: root/third_party/rust/darling_core/src/options/forward_attrs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/darling_core/src/options/forward_attrs.rs')
-rw-r--r--third_party/rust/darling_core/src/options/forward_attrs.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/third_party/rust/darling_core/src/options/forward_attrs.rs b/third_party/rust/darling_core/src/options/forward_attrs.rs
new file mode 100644
index 0000000000..ac9f4e1a84
--- /dev/null
+++ b/third_party/rust/darling_core/src/options/forward_attrs.rs
@@ -0,0 +1,30 @@
+use crate::ast::NestedMeta;
+use crate::util::PathList;
+use crate::{FromMeta, Result};
+
+/// A rule about which attributes to forward to the generated struct.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum ForwardAttrs {
+ All,
+ Only(PathList),
+}
+
+impl ForwardAttrs {
+ /// Returns `true` if this will not forward any attributes.
+ pub fn is_empty(&self) -> bool {
+ match *self {
+ ForwardAttrs::All => false,
+ ForwardAttrs::Only(ref list) => list.is_empty(),
+ }
+ }
+}
+
+impl FromMeta for ForwardAttrs {
+ fn from_word() -> Result<Self> {
+ Ok(ForwardAttrs::All)
+ }
+
+ fn from_list(nested: &[NestedMeta]) -> Result<Self> {
+ Ok(ForwardAttrs::Only(PathList::from_list(nested)?))
+ }
+}