aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_api.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-08 12:32:27 +0000
committerAleksey Kladov <[email protected]>2019-01-08 12:32:27 +0000
commit64f202bdd7f74b081e08f2b5faee4bd91c9b44a8 (patch)
tree33a664d30f32657fdc652fc32efb4665f25c90da /crates/ra_hir/src/code_model_api.rs
parent2d0ab52212f62345ba9f9d5040c553e59460b349 (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.rs27
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
146impl 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)]
147pub struct Struct { 174pub struct Struct {
148 pub(crate) def_id: DefId, 175 pub(crate) def_id: DefId,