mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
rename struct field -> struct field data
This commit is contained in:
parent
ae97cd59ff
commit
47e5536678
1 changed files with 6 additions and 6 deletions
|
@ -118,7 +118,7 @@ pub struct EnumVariantData {
|
||||||
|
|
||||||
/// A single field of an enum variant or struct
|
/// A single field of an enum variant or struct
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct StructField {
|
pub struct StructFieldData {
|
||||||
pub(crate) name: Name,
|
pub(crate) name: Name,
|
||||||
pub(crate) type_ref: TypeRef,
|
pub(crate) type_ref: TypeRef,
|
||||||
}
|
}
|
||||||
|
@ -126,13 +126,13 @@ pub struct StructField {
|
||||||
/// Fields of an enum variant or struct
|
/// Fields of an enum variant or struct
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum VariantData {
|
pub enum VariantData {
|
||||||
Struct(Vec<StructField>),
|
Struct(Vec<StructFieldData>),
|
||||||
Tuple(Vec<StructField>),
|
Tuple(Vec<StructFieldData>),
|
||||||
Unit,
|
Unit,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VariantData {
|
impl VariantData {
|
||||||
pub fn fields(&self) -> &[StructField] {
|
pub fn fields(&self) -> &[StructFieldData] {
|
||||||
match self {
|
match self {
|
||||||
VariantData::Struct(fields) | VariantData::Tuple(fields) => fields,
|
VariantData::Struct(fields) | VariantData::Tuple(fields) => fields,
|
||||||
_ => &[],
|
_ => &[],
|
||||||
|
@ -168,7 +168,7 @@ impl VariantData {
|
||||||
let fields = fl
|
let fields = fl
|
||||||
.fields()
|
.fields()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, fd)| StructField {
|
.map(|(i, fd)| StructFieldData {
|
||||||
name: Name::tuple_field_name(i),
|
name: Name::tuple_field_name(i),
|
||||||
type_ref: TypeRef::from_ast_opt(fd.type_ref()),
|
type_ref: TypeRef::from_ast_opt(fd.type_ref()),
|
||||||
})
|
})
|
||||||
|
@ -178,7 +178,7 @@ impl VariantData {
|
||||||
StructFlavor::Named(fl) => {
|
StructFlavor::Named(fl) => {
|
||||||
let fields = fl
|
let fields = fl
|
||||||
.fields()
|
.fields()
|
||||||
.map(|fd| StructField {
|
.map(|fd| StructFieldData {
|
||||||
name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing),
|
name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing),
|
||||||
type_ref: TypeRef::from_ast_opt(fd.type_ref()),
|
type_ref: TypeRef::from_ast_opt(fd.type_ref()),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue