diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-24 19:45:08 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-24 19:45:08 +0000 |
commit | f16cff3cad931d48a5516b2aec468cfddbed7dd1 (patch) | |
tree | 7daaf3dc8595dc8f431e84db6469c7fa02f6e680 /crates/ra_hir_def | |
parent | 09389ed1d43c244352cecbd78c8685480d60157d (diff) | |
parent | 586acef5283e78f19e5e9daf4e8aac40e2a9ff16 (diff) |
Merge #2393
2393: Simplify ADT fields r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index a43f553aa..c9f30923e 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -109,10 +109,18 @@ impl VariantData { | |||
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | pub fn fields(&self) -> Option<&Arena<LocalStructFieldId, StructFieldData>> { | 112 | pub fn fields(&self) -> &Arena<LocalStructFieldId, StructFieldData> { |
113 | const EMPTY: &Arena<LocalStructFieldId, StructFieldData> = &Arena::new(); | ||
113 | match &self { | 114 | match &self { |
114 | VariantData::Record(fields) | VariantData::Tuple(fields) => Some(fields), | 115 | VariantData::Record(fields) | VariantData::Tuple(fields) => fields, |
115 | _ => None, | 116 | _ => EMPTY, |
117 | } | ||
118 | } | ||
119 | |||
120 | pub fn is_unit(&self) -> bool { | ||
121 | match self { | ||
122 | VariantData::Unit => true, | ||
123 | _ => false, | ||
116 | } | 124 | } |
117 | } | 125 | } |
118 | } | 126 | } |