From 586acef5283e78f19e5e9daf4e8aac40e2a9ff16 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Nov 2019 22:44:24 +0300 Subject: Simplify ADT fields --- crates/ra_hir_def/src/adt.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir_def/src') 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 { } } - pub fn fields(&self) -> Option<&Arena> { + pub fn fields(&self) -> &Arena { + const EMPTY: &Arena = &Arena::new(); match &self { - VariantData::Record(fields) | VariantData::Tuple(fields) => Some(fields), - _ => None, + VariantData::Record(fields) | VariantData::Tuple(fields) => fields, + _ => EMPTY, + } + } + + pub fn is_unit(&self) -> bool { + match self { + VariantData::Unit => true, + _ => false, } } } -- cgit v1.2.3