mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
complete fields in enum variants
This commit is contained in:
parent
8bb81d7418
commit
2a1e11b36f
5 changed files with 116 additions and 16 deletions
|
@ -185,6 +185,13 @@ pub enum VariantDef {
|
|||
impl_froms!(VariantDef: Struct, EnumVariant);
|
||||
|
||||
impl VariantDef {
|
||||
pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> {
|
||||
match self {
|
||||
VariantDef::Struct(it) => it.fields(db),
|
||||
VariantDef::EnumVariant(it) => it.fields(db),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
|
||||
match self {
|
||||
VariantDef::Struct(it) => it.field(db, name),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue