Allman struct and enum field style
This commit is contained in:
@@ -126,6 +126,7 @@ pub struct FieldDecl {
|
||||
pub visibility: Visibility,
|
||||
pub type_: TypeExpr,
|
||||
pub name: Identifier,
|
||||
// pub tuple_names: Vec<Identifier>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
|
||||
@@ -240,7 +240,7 @@ param = {
|
||||
}
|
||||
|
||||
field_list = {
|
||||
(field ~ ("," ~ field)* ~ ","?)?
|
||||
(field ~ ";")*
|
||||
}
|
||||
|
||||
param_list = {
|
||||
@@ -264,7 +264,7 @@ declare_module = {
|
||||
// ======================================================
|
||||
|
||||
struct_decl = {
|
||||
visibility? ~ "struct" ~ identifier ~ generics_decl? ~ "{" ~ field_list? ~ "}"
|
||||
visibility? ~ "struct" ~ identifier ~ generics_decl? ~ "{" ~ field_list ~ "}"
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
@@ -290,7 +290,7 @@ enum_field = _{
|
||||
}
|
||||
|
||||
enum_fields = _{
|
||||
enum_field ~ ("," ~ enum_field)* ~ ","?
|
||||
enum_field ~ ";"
|
||||
}
|
||||
|
||||
enum_decl = {
|
||||
|
||||
@@ -54,11 +54,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for TopLevelKind {
|
||||
.transpose()
|
||||
.map(|v| v.unwrap_or_default())?,
|
||||
|
||||
fields: inner
|
||||
.next()
|
||||
.map(|pair| collect_recovered(pair.into_inner()))
|
||||
.transpose()
|
||||
.map(|v| v.unwrap_or_default())?,
|
||||
fields: collect_recovered(inner.next().unwrap().into_inner())?,
|
||||
}),
|
||||
|
||||
Rule::class_decl => Ok(TopLevelKind::ClassDecl {
|
||||
|
||||
Reference in New Issue
Block a user