This commit is contained in:
2026-05-10 17:55:08 +02:00
parent 28d4d784f2
commit e063d4c685
4 changed files with 60 additions and 2 deletions
+19 -1
View File
@@ -259,6 +259,24 @@ impl_decl = {
"impl" ~ generics? ~ type_expr ~ "{" ~ method* ~ "}"
}
// ======================================================
// Traits
// ======================================================
trait_requirements = { ":" ~ type_expr_param ~ ("+" ~ type_expr_param)* }
method_no_body = {
export? ~ type_expr ~ identifier ~ generics? ~ "(" ~ self_param? ~ ("," ~ param_list?)? ~ ")"
}
trait_item = _{
method
| method_no_body
}
trait_decl = {
export? ~ "trait" ~ identifier ~ generics? ~ trait_requirements? ~ "{" ~ trait_item* ~ "}"
}
// ======================================================
// FUNCTIONS
// ======================================================
@@ -272,7 +290,7 @@ function_decl = {
// ======================================================
top_level = {
(attributes ~ (import | impl_for_decl | impl_decl | function_decl | struct_decl | enum_decl | class_decl | mod_package))
(attributes ~ (import | impl_for_decl | impl_decl | trait_decl | struct_decl | enum_decl | class_decl | mod_package | function_decl))
| mod_attribute
}