Identifier setting via struct #59
This commit is contained in:
@@ -200,8 +200,10 @@ impl GenRust for Postfix {
|
||||
|
||||
for (name, expr) in fields {
|
||||
cg.add(&name.get_rust());
|
||||
if let Some(expr) = expr {
|
||||
cg.add(": ");
|
||||
expr.gen_rust(ctx, cg);
|
||||
}
|
||||
cg.add(",");
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ pub enum Postfix {
|
||||
inner: String,
|
||||
delimiter: MacroDelimiter,
|
||||
},
|
||||
StructCall(Vec<(Identifier, Expression)>),
|
||||
StructCall(Vec<(Identifier, Option<Expression>)>),
|
||||
Assign(String, Box<Expression>),
|
||||
Index(Expression),
|
||||
As(TypeExpr),
|
||||
|
||||
@@ -523,7 +523,7 @@ macro_call_bracket = { "!" ~ "[" ~ macro_inner_v* ~ "]" }
|
||||
macro_call_brace = { "!" ~ "{" ~ macro_inner_v* ~ "}" }
|
||||
|
||||
struct_field_decl = {
|
||||
identifier ~ ":" ~ expr
|
||||
identifier ~ (":" ~ expr)?
|
||||
}
|
||||
|
||||
struct_px = {
|
||||
|
||||
@@ -155,7 +155,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Postfix {
|
||||
let mut pi = p.into_inner();
|
||||
Ok((
|
||||
Identifier::try_from(pi.next().unwrap())?,
|
||||
Expression::try_from(pi.next().unwrap()).get()?,
|
||||
pi.next().map(Expression::try_from).transpose().get()?,
|
||||
))
|
||||
}))),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user