mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Implement basic completion for fields
This commit is contained in:
parent
0d724ea572
commit
ab0b63992b
10 changed files with 156 additions and 12 deletions
|
@ -124,6 +124,15 @@ pub struct StructField {
|
|||
ty: Ty,
|
||||
}
|
||||
|
||||
impl StructField {
|
||||
pub fn name(&self) -> SmolStr {
|
||||
self.name.clone()
|
||||
}
|
||||
pub fn ty(&self) -> Ty {
|
||||
self.ty.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// Fields of an enum variant or struct
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum VariantData {
|
||||
|
@ -168,7 +177,10 @@ impl VariantData {
|
|||
}
|
||||
|
||||
pub(crate) fn get_field_ty(&self, field_name: &str) -> Option<Ty> {
|
||||
self.fields().iter().find(|f| f.name == field_name).map(|f| f.ty.clone())
|
||||
self.fields()
|
||||
.iter()
|
||||
.find(|f| f.name == field_name)
|
||||
.map(|f| f.ty.clone())
|
||||
}
|
||||
|
||||
pub fn fields(&self) -> &[StructField] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue