Fixed class lifetimes
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
mod app;
|
|
||||||
mod task;
|
|
||||||
mod plugin;
|
|
||||||
mod logger;
|
|
||||||
mod event;
|
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
mod core;
|
mod app;
|
||||||
|
mod task;
|
||||||
|
mod plugin;
|
||||||
|
mod logger;
|
||||||
|
mod event;
|
||||||
|
|
||||||
use <core::app>;
|
use <app>;
|
||||||
// use <plugins::greeting>;
|
// use <plugins::greeting>;
|
||||||
// use <plugins::statistics>;
|
// use <plugins::statistics>;
|
||||||
|
|
||||||
|
|||||||
+31
-12
@@ -1,7 +1,7 @@
|
|||||||
use parser::ast::{
|
use parser::ast::{
|
||||||
Attribute, BinaryOp, Block, EnumItem, Expression, FunctionDecl, Generics, Identifier, Literal,
|
Attribute, BinaryOp, Block, EnumItem, Expression, FunctionDecl, Generic, Generics, Identifier,
|
||||||
Path, Pattern, Postfix, Prefix, Statement, StatementBranch, TopLevel, TopLevelKind, TypeExpr,
|
Literal, Path, Pattern, Postfix, Prefix, Statement, StatementBranch, TopLevel, TopLevelKind,
|
||||||
TypeExprKind, TypePostfix, VarAssignStmt, VarDecl, VarDeclStmt, Visibility,
|
TypeExpr, TypeExprKind, TypePostfix, VarAssignStmt, VarDecl, VarDeclStmt, Visibility,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -383,7 +383,20 @@ impl ToRust for TopLevelKind {
|
|||||||
cg.addln("}\n");
|
cg.addln("}\n");
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
cg.addln(&format!("impl {} {{", name.get_rust()));
|
cg.addln(&format!(
|
||||||
|
"impl{} {}{} {{",
|
||||||
|
generics.get_rust(),
|
||||||
|
name.get_rust(),
|
||||||
|
format!(
|
||||||
|
"<{}>",
|
||||||
|
generics
|
||||||
|
.0
|
||||||
|
.iter()
|
||||||
|
.map(|v| (false, v).get_rust())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(", ")
|
||||||
|
)
|
||||||
|
));
|
||||||
cg.indent += 1;
|
cg.indent += 1;
|
||||||
|
|
||||||
let params_str = constructor
|
let params_str = constructor
|
||||||
@@ -725,11 +738,21 @@ impl GetRust for Generics {
|
|||||||
"<{}>",
|
"<{}>",
|
||||||
self.0
|
self.0
|
||||||
.iter()
|
.iter()
|
||||||
.map(|generic| match generic {
|
.map(|v| (true, v).get_rust())
|
||||||
parser::ast::Generic::Lifetime(name) => format!("'{}", name.get_rust()),
|
.collect::<Vec<_>>()
|
||||||
parser::ast::Generic::Type(name, requirements) => {
|
.join(", ")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GetRust for (bool, &Generic) {
|
||||||
|
fn get_rust(&self) -> String {
|
||||||
|
match &self.1 {
|
||||||
|
Generic::Lifetime(name) => format!("'{}", name.get_rust()),
|
||||||
|
Generic::Type(name, requirements) => {
|
||||||
name.get_rust()
|
name.get_rust()
|
||||||
+ &(if requirements.len() == 0 {
|
+ &(if !self.0 && requirements.len() == 0 {
|
||||||
String::new()
|
String::new()
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(
|
||||||
@@ -742,10 +765,6 @@ impl GetRust for Generics {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(", ")
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user