diff options
author | Aleksey Kladov <[email protected]> | 2019-01-08 12:32:27 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-08 12:32:27 +0000 |
commit | 64f202bdd7f74b081e08f2b5faee4bd91c9b44a8 (patch) | |
tree | 33a664d30f32657fdc652fc32efb4665f25c90da /crates/ra_hir/src/code_model_api.rs | |
parent | 2d0ab52212f62345ba9f9d5040c553e59460b349 (diff) |
move variant public api to api
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 27 |
1 files changed, 27 insertions, 0 deletions
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 { | |||
143 | Unit, | 143 | Unit, |
144 | } | 144 | } |
145 | 145 | ||
146 | impl VariantData { | ||
147 | pub fn fields(&self) -> &[StructField] { | ||
148 | match self { | ||
149 | VariantData::Struct(fields) | VariantData::Tuple(fields) => fields, | ||
150 | _ => &[], | ||
151 | } | ||
152 | } | ||
153 | pub fn is_struct(&self) -> bool { | ||
154 | match self { | ||
155 | VariantData::Struct(..) => true, | ||
156 | _ => false, | ||
157 | } | ||
158 | } | ||
159 | pub fn is_tuple(&self) -> bool { | ||
160 | match self { | ||
161 | VariantData::Tuple(..) => true, | ||
162 | _ => false, | ||
163 | } | ||
164 | } | ||
165 | pub fn is_unit(&self) -> bool { | ||
166 | match self { | ||
167 | VariantData::Unit => true, | ||
168 | _ => false, | ||
169 | } | ||
170 | } | ||
171 | } | ||
172 | |||
146 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 173 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
147 | pub struct Struct { | 174 | pub struct Struct { |
148 | pub(crate) def_id: DefId, | 175 | pub(crate) def_id: DefId, |