Allman struct and enum field style

This commit is contained in:
2026-07-04 09:38:13 +02:00
parent 409301b3d6
commit 4f3966d8d8
6 changed files with 21 additions and 20 deletions
+1 -5
View File
@@ -289,12 +289,8 @@ enum_field = _{
| enum_named | enum_named
} }
enum_fields = _{
enum_field ~ ";"
}
enum_decl = { enum_decl = {
visibility? ~ "enum" ~ identifier ~ generics_decl? ~ "{" ~ enum_fields? ~ "}" visibility? ~ "enum" ~ identifier ~ generics_decl? ~ "{" ~ (enum_field ~ ";")* ~ "}"
} }
// ====================================================== // ======================================================
+1 -1
View File
@@ -4,7 +4,7 @@ pub module attribute_test;
#[derive(Debug)] #[derive(Debug)]
pub struct Debuggable pub struct Debuggable
{ {
i32 value, i32 value;
} }
pub void test_derive_attribute() pub void test_derive_attribute()
+12 -7
View File
@@ -3,8 +3,8 @@ pub module enum_test;
enum OptionInt enum OptionInt
{ {
None, None;
Some(i32), Some(i32);
} }
pub void test_enum_named() pub void test_enum_named()
@@ -35,8 +35,13 @@ pub void test_enum_tuple()
enum Shape enum Shape
{ {
Circle {i32 radius}, Circle {
Rect {i32 w, i32 h}, i32 radius;
};
Rect {
i32 w;
i32 h;
};
} }
pub void test_enum_struct() pub void test_enum_struct()
@@ -68,9 +73,9 @@ pub void test_enum_struct()
enum Color enum Color
{ {
Red, Red;
Green, Green;
Blue, Blue;
} }
pub void test_enum_eq() pub void test_enum_eq()
+2 -2
View File
@@ -3,8 +3,8 @@ pub module impl_test;
struct Vector2 struct Vector2
{ {
i32 x, i32 x;
i32 y, i32 y;
} }
impl Vector2 impl Vector2
+4 -4
View File
@@ -3,8 +3,8 @@ pub module struct_test;
struct Point struct Point
{ {
i32 x, i32 x;
i32 y, i32 y;
} }
pub void test_struct_create_access() pub void test_struct_create_access()
@@ -40,8 +40,8 @@ pub void test_struct_destructure()
struct Line struct Line
{ {
Point start, Point start;
Point end, Point end;
} }
pub void test_struct_nested() pub void test_struct_nested()
+1 -1
View File
@@ -13,7 +13,7 @@ trait Greet : Speak
struct Dog struct Dog
{ {
String name, String name;
} }
impl Speak for Dog impl Speak for Dog