Type expr refrence

This commit is contained in:
2026-05-04 17:47:04 +02:00
parent 0e84e1ca3d
commit a057c50a53
+12 -10
View File
@@ -1,6 +1,6 @@
use parser::ast::{ use parser::ast::{
BinaryOp, Block, Expression, IfStmt, Postfix, Statement, StaticPath, TopLevel, TypeExpr, BinaryOp, Block, Expression, IfStmt, Postfix, Statement, StaticPath, TopLevel, TypeExpr,
TypePostfix, VarAssignStmt, VarDecl, VarDeclStmt, WhileStmt, TypeExprKind, TypePostfix, VarAssignStmt, VarDecl, VarDeclStmt, WhileStmt,
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -73,15 +73,18 @@ impl Default for RustCodegen {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
impl GetRust for TypeExpr { impl GetRust for TypeExpr {
fn get_rust(&self) -> String {
get_type_postfixes(&self.1) + &self.0.get_rust()
}
}
impl GetRust for TypeExprKind {
fn get_rust(&self) -> String { fn get_rust(&self) -> String {
match self { match self {
TypeExpr::Path(path, postix) => { TypeExprKind::Path(path) => get_static_type_path(path),
get_type_postfixes(postix) + &get_static_type_path(path) TypeExprKind::PathParams(path, params) => {
}
TypeExpr::PathParams(path, params, postfix) => {
format!( format!(
"{}{}<{}>", "{}<{}>",
get_type_postfixes(postix),
get_static_type_path(path), get_static_type_path(path),
params params
.iter() .iter()
@@ -90,9 +93,8 @@ impl GetRust for TypeExpr {
.join(", ") .join(", ")
) )
} }
TypeExpr::Tuple(types, postfix) => format!( TypeExprKind::Tuple(types) => format!(
"{}({})", "({})",
get_type_postfixes(postix),
types types
.iter() .iter()
.map(|t| t.get_rust()) .map(|t| t.get_rust())