Type expr refrence
This commit is contained in:
+12
-10
@@ -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,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -74,14 +74,17 @@ impl Default for RustCodegen {
|
|||||||
|
|
||||||
impl GetRust for TypeExpr {
|
impl GetRust for TypeExpr {
|
||||||
fn get_rust(&self) -> String {
|
fn get_rust(&self) -> String {
|
||||||
match self {
|
get_type_postfixes(&self.1) + &self.0.get_rust()
|
||||||
TypeExpr::Path(path, postix) => {
|
|
||||||
get_type_postfixes(postix) + &get_static_type_path(path)
|
|
||||||
}
|
}
|
||||||
TypeExpr::PathParams(path, params, postfix) => {
|
}
|
||||||
|
|
||||||
|
impl GetRust for TypeExprKind {
|
||||||
|
fn get_rust(&self) -> String {
|
||||||
|
match self {
|
||||||
|
TypeExprKind::Path(path) => get_static_type_path(path),
|
||||||
|
TypeExprKind::PathParams(path, params) => {
|
||||||
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())
|
||||||
|
|||||||
Reference in New Issue
Block a user