Class constructor (optional)

This commit is contained in:
2026-05-05 20:11:43 +02:00
parent 8bb5dc3584
commit 9e5d030b0c
5 changed files with 29 additions and 2 deletions
+24 -1
View File
@@ -148,7 +148,12 @@ impl GetRust for Expression {
initial,
prefixes,
postfixes,
} => prefixes.get_rust() + &initial.get_rust() + &postfixes.get_rust(),
} => {
prefixes.get_rust()
+ &initial.get_rust()
+ &Some(prefixes).get_rust()
+ &postfixes.get_rust()
}
}
}
}
@@ -159,6 +164,7 @@ impl GetRust for Prefix {
Self::Deref => "*",
Self::Ref => "&",
Self::RefMut => "&mut ",
Self::New => "",
}
.to_string()
}
@@ -170,6 +176,23 @@ impl GetRust for [Prefix] {
}
}
impl GetRust for Option<&Vec<Prefix>> {
fn get_rust(&self) -> String {
self.map(|prefixes| {
prefixes
.iter()
.last()
.map(|p| match p {
Prefix::New => "::new",
_ => "",
})
.unwrap_or_default()
.to_string()
})
.unwrap_or_default()
}
}
impl GetRust for Postfix {
fn get_rust(&self) -> String {
match self {