aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/attr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/attr.rs')
-rw-r--r--crates/ra_hir_def/src/attr.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs
index deea83a6d..e0f468bf3 100644
--- a/crates/ra_hir_def/src/attr.rs
+++ b/crates/ra_hir_def/src/attr.rs
@@ -107,6 +107,18 @@ impl Attrs {
107 Attrs { entries } 107 Attrs { entries }
108 } 108 }
109 109
110 pub fn merge(&self, other: Attrs) -> Attrs {
111 match (&self.entries, &other.entries) {
112 (None, None) => Attrs { entries: None },
113 (Some(entries), None) | (None, Some(entries)) => {
114 Attrs { entries: Some(entries.clone()) }
115 }
116 (Some(a), Some(b)) => {
117 Attrs { entries: Some(a.iter().chain(b.iter()).cloned().collect()) }
118 }
119 }
120 }
121
110 pub fn by_key(&self, key: &'static str) -> AttrQuery<'_> { 122 pub fn by_key(&self, key: &'static str) -> AttrQuery<'_> {
111 AttrQuery { attrs: self, key } 123 AttrQuery { attrs: self, key }
112 } 124 }