Removed new keyword
This commit is contained in:
@@ -87,7 +87,6 @@ impl GenRust for Expression {
|
|||||||
} => {
|
} => {
|
||||||
prefixes.gen_rust(ctx, cg);
|
prefixes.gen_rust(ctx, cg);
|
||||||
initial.gen_rust(ctx, cg);
|
initial.gen_rust(ctx, cg);
|
||||||
cg.add(&Some(prefixes).get_rust());
|
|
||||||
for postfix in postfixes {
|
for postfix in postfixes {
|
||||||
postfix.gen_rust(ctx, cg);
|
postfix.gen_rust(ctx, cg);
|
||||||
}
|
}
|
||||||
@@ -117,7 +116,6 @@ impl GenRust for Prefix {
|
|||||||
Self::Ref => cg.add("&"),
|
Self::Ref => cg.add("&"),
|
||||||
Self::RefMut => cg.add("&mut "),
|
Self::RefMut => cg.add("&mut "),
|
||||||
Self::Not => cg.add("!"),
|
Self::Not => cg.add("!"),
|
||||||
Self::New(_) => cg.add(""),
|
|
||||||
Self::Neg => cg.add("-"),
|
Self::Neg => cg.add("-"),
|
||||||
Self::Closure(ty, args) => {
|
Self::Closure(ty, args) => {
|
||||||
cg.add("|");
|
cg.add("|");
|
||||||
@@ -148,30 +146,6 @@ impl GenRust for Vec<Prefix> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetRust for Option<&Vec<Prefix>> {
|
|
||||||
fn get_rust(&self) -> String {
|
|
||||||
if let Some(prefixes) = self {
|
|
||||||
prefixes
|
|
||||||
.into_iter()
|
|
||||||
.last()
|
|
||||||
.map(|p| match p {
|
|
||||||
Prefix::New(generics) => format!(
|
|
||||||
"::new{}",
|
|
||||||
generics
|
|
||||||
.clone()
|
|
||||||
.map(|v| format!("::{}", v.get_rust()))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
),
|
|
||||||
_ => String::new(),
|
|
||||||
})
|
|
||||||
.unwrap_or_default()
|
|
||||||
.to_string()
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GenRust for Postfix {
|
impl GenRust for Postfix {
|
||||||
fn gen_rust(&self, ctx: &mut Context, cg: &mut RustCodegen) {
|
fn gen_rust(&self, ctx: &mut Context, cg: &mut RustCodegen) {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ pub enum Prefix {
|
|||||||
Ref,
|
Ref,
|
||||||
RefMut,
|
RefMut,
|
||||||
Deref,
|
Deref,
|
||||||
New(Option<Generics>),
|
|
||||||
Not,
|
Not,
|
||||||
Neg,
|
Neg,
|
||||||
Closure(Option<TypeExpr>, Vec<VarDecl>),
|
Closure(Option<TypeExpr>, Vec<VarDecl>),
|
||||||
|
|||||||
@@ -562,7 +562,6 @@ postfix = {
|
|||||||
deref_px = { "*" }
|
deref_px = { "*" }
|
||||||
mut_ref_px = { "&" ~ mutable }
|
mut_ref_px = { "&" ~ mutable }
|
||||||
ref_px = { "&" }
|
ref_px = { "&" }
|
||||||
new_px = { "new" ~ generics? }
|
|
||||||
not_px = { "!" }
|
not_px = { "!" }
|
||||||
neg_px = { "-" }
|
neg_px = { "-" }
|
||||||
|
|
||||||
@@ -571,7 +570,6 @@ prefix = {
|
|||||||
| deref_px
|
| deref_px
|
||||||
| mut_ref_px
|
| mut_ref_px
|
||||||
| ref_px
|
| ref_px
|
||||||
| new_px
|
|
||||||
| not_px
|
| not_px
|
||||||
| neg_px
|
| neg_px
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,12 +106,6 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Prefix {
|
|||||||
Rule::deref_px => Self::Deref,
|
Rule::deref_px => Self::Deref,
|
||||||
Rule::mut_ref_px => Self::RefMut,
|
Rule::mut_ref_px => Self::RefMut,
|
||||||
Rule::ref_px => Self::Ref,
|
Rule::ref_px => Self::Ref,
|
||||||
Rule::new_px => Self::New(
|
|
||||||
pair.into_inner()
|
|
||||||
.next()
|
|
||||||
.map(|v| v.try_into().get())
|
|
||||||
.transpose()?,
|
|
||||||
),
|
|
||||||
Rule::not_px => Self::Not,
|
Rule::not_px => Self::Not,
|
||||||
Rule::neg_px => Self::Neg,
|
Rule::neg_px => Self::Neg,
|
||||||
Rule::closure => {
|
Rule::closure => {
|
||||||
|
|||||||
Reference in New Issue
Block a user