Fixed attributes
This commit is contained in:
@@ -108,11 +108,12 @@ impl GenRust for Attribute {
|
|||||||
match self {
|
match self {
|
||||||
Self::Path(path) => cg.add(&path.get_rust()),
|
Self::Path(path) => cg.add(&path.get_rust()),
|
||||||
Self::NameValue { path, value } => {
|
Self::NameValue { path, value } => {
|
||||||
cg.add(&format!("{} =", path.get_rust()));
|
cg.add(&format!("{} = ", path.get_rust()));
|
||||||
value.gen_rust(ctx, cg);
|
value.gen_rust(ctx, cg);
|
||||||
}
|
}
|
||||||
Self::List { path, items } => {
|
Self::List { path, items } => {
|
||||||
cg.add(&path.get_rust());
|
cg.add(&path.get_rust());
|
||||||
|
cg.add("(");
|
||||||
for (i, item) in items.iter().enumerate() {
|
for (i, item) in items.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
cg.add(", ");
|
cg.add(", ");
|
||||||
@@ -120,6 +121,7 @@ impl GenRust for Attribute {
|
|||||||
|
|
||||||
item.gen_rust(ctx, cg);
|
item.gen_rust(ctx, cg);
|
||||||
}
|
}
|
||||||
|
cg.add(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Attribute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Some(next) => match next.as_rule() {
|
Some(next) => match next.as_rule() {
|
||||||
Rule::primary => {
|
Rule::literal => {
|
||||||
// #[path = literal]
|
// #[path = literal]
|
||||||
Ok(Attribute::NameValue {
|
Ok(Attribute::NameValue {
|
||||||
path,
|
path,
|
||||||
value: inner.next().unwrap().try_into().get()?,
|
value: next.try_into().get()?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user