Allman struct and enum field style

This commit is contained in:
2026-07-04 09:16:13 +02:00
parent 223bafaad7
commit 409301b3d6
3 changed files with 5 additions and 8 deletions
+1
View File
@@ -126,6 +126,7 @@ pub struct FieldDecl {
pub visibility: Visibility, pub visibility: Visibility,
pub type_: TypeExpr, pub type_: TypeExpr,
pub name: Identifier, pub name: Identifier,
// pub tuple_names: Vec<Identifier>,
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
+3 -3
View File
@@ -240,7 +240,7 @@ param = {
} }
field_list = { field_list = {
(field ~ ("," ~ field)* ~ ","?)? (field ~ ";")*
} }
param_list = { param_list = {
@@ -264,7 +264,7 @@ declare_module = {
// ====================================================== // ======================================================
struct_decl = { 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_fields = _{
enum_field ~ ("," ~ enum_field)* ~ ","? enum_field ~ ";"
} }
enum_decl = { enum_decl = {
+1 -5
View File
@@ -54,11 +54,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for TopLevelKind {
.transpose() .transpose()
.map(|v| v.unwrap_or_default())?, .map(|v| v.unwrap_or_default())?,
fields: inner fields: collect_recovered(inner.next().unwrap().into_inner())?,
.next()
.map(|pair| collect_recovered(pair.into_inner()))
.transpose()
.map(|v| v.unwrap_or_default())?,
}), }),
Rule::class_decl => Ok(TopLevelKind::ClassDecl { Rule::class_decl => Ok(TopLevelKind::ClassDecl {