Constructor generics

This commit is contained in:
2026-05-08 17:14:39 +02:00
parent bbcc639331
commit 65f4c5278d
4 changed files with 11 additions and 3 deletions
+1
View File
@@ -120,6 +120,7 @@ pub enum EnumItem {
#[derive(Debug, Clone, Serialize)]
pub struct ClassConstructor {
pub visibility: Visibility,
pub generics: Generics,
pub params: ParamList,
pub body: Block,
}
+1 -1
View File
@@ -212,7 +212,7 @@ enum_decl = {
// ======================================================
class_constructor = {
export? ~ "constructor" ~ "(" ~ param_list? ~ ")" ~ block
export? ~ "constructor" ~ generics? ~ "(" ~ param_list? ~ ")" ~ block
}
class_fields = {
+5
View File
@@ -211,12 +211,17 @@ impl From<pest::iterators::Pair<'_, Rule>> for ClassConstructor {
let visibility = Visibility::from(&mut inner);
let generics = consume_rule(&mut inner, Rule::generics)
.map(Generics::from)
.unwrap_or_default();
let params = consume_rule(&mut inner, Rule::param_list)
.map(ParamList::from)
.unwrap_or_else(|| ParamList(Vec::new()));
Self {
visibility,
generics,
params,
body: Block::from(inner.next().unwrap()),
}