mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
move variant public api to api
This commit is contained in:
parent
2d0ab52212
commit
64f202bdd7
2 changed files with 28 additions and 34 deletions
|
@ -26,14 +26,6 @@ impl StructData {
|
||||||
let variant_data = Arc::new(variant_data);
|
let variant_data = Arc::new(variant_data);
|
||||||
StructData { name, variant_data }
|
StructData { name, variant_data }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> Option<&Name> {
|
|
||||||
self.name.as_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn variant_data(&self) -> &Arc<VariantData> {
|
|
||||||
&self.variant_data
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Enum {
|
impl Enum {
|
||||||
|
@ -68,7 +60,7 @@ impl EnumData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VariantData {
|
impl VariantData {
|
||||||
pub fn new(flavor: StructFlavor) -> Self {
|
pub(crate) fn new(flavor: StructFlavor) -> Self {
|
||||||
match flavor {
|
match flavor {
|
||||||
StructFlavor::Tuple(fl) => {
|
StructFlavor::Tuple(fl) => {
|
||||||
let fields = fl
|
let fields = fl
|
||||||
|
@ -101,29 +93,4 @@ impl VariantData {
|
||||||
.find(|f| f.name() == field_name)
|
.find(|f| f.name() == field_name)
|
||||||
.map(|f| f.type_ref())
|
.map(|f| f.type_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fields(&self) -> &[StructField] {
|
|
||||||
match *self {
|
|
||||||
VariantData::Struct(ref fields) | VariantData::Tuple(ref fields) => fields,
|
|
||||||
_ => &[],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn is_struct(&self) -> bool {
|
|
||||||
match self {
|
|
||||||
VariantData::Struct(..) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn is_tuple(&self) -> bool {
|
|
||||||
match self {
|
|
||||||
VariantData::Tuple(..) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn is_unit(&self) -> bool {
|
|
||||||
match self {
|
|
||||||
VariantData::Unit => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,6 +143,33 @@ pub enum VariantData {
|
||||||
Unit,
|
Unit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl VariantData {
|
||||||
|
pub fn fields(&self) -> &[StructField] {
|
||||||
|
match self {
|
||||||
|
VariantData::Struct(fields) | VariantData::Tuple(fields) => fields,
|
||||||
|
_ => &[],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn is_struct(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
VariantData::Struct(..) => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn is_tuple(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
VariantData::Tuple(..) => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn is_unit(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
VariantData::Unit => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct Struct {
|
pub struct Struct {
|
||||||
pub(crate) def_id: DefId,
|
pub(crate) def_id: DefId,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue