aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/adt.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2018-12-25 14:15:40 +0000
committerFlorian Diebold <[email protected]>2018-12-25 14:27:15 +0000
commitab0b63992be0cec4999810096a53b40f63f90349 (patch)
tree5e6dca70c4e842bc87e6e1287cca176031ecc92f /crates/ra_hir/src/adt.rs
parent0d724ea572a5dd26acbbf2eb4538eabe454fb894 (diff)
Implement basic completion for fields
Diffstat (limited to 'crates/ra_hir/src/adt.rs')
-rw-r--r--crates/ra_hir/src/adt.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
index 03770ed7d..e65f8deb8 100644
--- a/crates/ra_hir/src/adt.rs
+++ b/crates/ra_hir/src/adt.rs
@@ -124,6 +124,15 @@ pub struct StructField {
124 ty: Ty, 124 ty: Ty,
125} 125}
126 126
127impl StructField {
128 pub fn name(&self) -> SmolStr {
129 self.name.clone()
130 }
131 pub fn ty(&self) -> Ty {
132 self.ty.clone()
133 }
134}
135
127/// Fields of an enum variant or struct 136/// Fields of an enum variant or struct
128#[derive(Debug, Clone, PartialEq, Eq)] 137#[derive(Debug, Clone, PartialEq, Eq)]
129pub enum VariantData { 138pub enum VariantData {
@@ -168,7 +177,10 @@ impl VariantData {
168 } 177 }
169 178
170 pub(crate) fn get_field_ty(&self, field_name: &str) -> Option<Ty> { 179 pub(crate) fn get_field_ty(&self, field_name: &str) -> Option<Ty> {
171 self.fields().iter().find(|f| f.name == field_name).map(|f| f.ty.clone()) 180 self.fields()
181 .iter()
182 .find(|f| f.name == field_name)
183 .map(|f| f.ty.clone())
172 } 184 }
173 185
174 pub fn fields(&self) -> &[StructField] { 186 pub fn fields(&self) -> &[StructField] {