From 64f202bdd7f74b081e08f2b5faee4bd91c9b44a8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 8 Jan 2019 15:32:27 +0300 Subject: move variant public api to api --- crates/ra_hir/src/code_model_api.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'crates/ra_hir/src/code_model_api.rs') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 3bb42ac58..f06f1ae66 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -143,6 +143,33 @@ pub enum VariantData { Unit, } +impl VariantData { + pub fn fields(&self) -> &[StructField] { + match self { + VariantData::Struct(fields) | VariantData::Tuple(fields) => fields, + _ => &[], + } + } + pub fn is_struct(&self) -> bool { + match self { + VariantData::Struct(..) => true, + _ => false, + } + } + pub fn is_tuple(&self) -> bool { + match self { + VariantData::Tuple(..) => true, + _ => false, + } + } + pub fn is_unit(&self) -> bool { + match self { + VariantData::Unit => true, + _ => false, + } + } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Struct { pub(crate) def_id: DefId, -- cgit v1.2.3