This commit is contained in:
2026-05-07 22:25:35 +02:00
parent a6fb70eebf
commit dc49cddc20
3 changed files with 43 additions and 9 deletions
+36 -2
View File
@@ -1,7 +1,7 @@
use parser::ast::{
Attribute, BinaryOp, Block, EnumItem, Expression, FunctionDecl, Identifier, Literal, Path,
Postfix, Prefix, Statement, StatementBranch, TopLevel, TopLevelKind, TypeExpr, TypeExprKind,
TypePostfix, VarAssignStmt, VarDecl, VarDeclStmt, Visibility,
Pattern, Postfix, Prefix, Statement, StatementBranch, TopLevel, TopLevelKind, TypeExpr,
TypeExprKind, TypePostfix, VarAssignStmt, VarDecl, VarDeclStmt, Visibility,
};
// ---------------------------------------------------------------------------
@@ -644,6 +644,40 @@ impl GetRust for EnumItem {
}
}
impl GetRust for Pattern {
fn get_rust(&self) -> String {
match self {
Self::Id(id) => id.get_rust(),
Self::Path(path) => path.get_rust(),
Self::Struct(path, ids) => format!(
"{} {{{}}}",
path.get_rust(),
ids.iter()
.map(Identifier::get_rust)
.collect::<Vec<_>>()
.join(", ")
),
Self::Tuple(ids) => format!(
"({})",
ids.iter()
.map(Identifier::get_rust)
.collect::<Vec<_>>()
.join(", ")
),
Self::NamedTuple(path, ids) => {
format!(
"{} ({})",
path.get_rust(),
ids.iter()
.map(Identifier::get_rust)
.collect::<Vec<_>>()
.join(", ")
)
}
}
}
}
pub fn get_static_type_path(path: &Path) -> String {
let rust_path = path.get_rust();