summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-04-28 23:58:03 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-04-28 23:58:03 +0200
commitfac5b015b92ea06eaff4be6c8a2a20d90e770ebb (patch)
treeb771ea962bab41db5d9ab3f1697ea1cab081af8b
parent54030e686915a07452a3d4bb5a23616eec30f4fa (diff)
downloadrebel-fac5b015b92ea06eaff4be6c8a2a20d90e770ebb.tar
rebel-fac5b015b92ea06eaff4be6c8a2a20d90e770ebb.zip
rebel-parse: rename struct field name from key to name
-rw-r--r--crates/rebel-lang/src/typing.rs4
-rw-r--r--crates/rebel-lang/src/value.rs4
-rw-r--r--crates/rebel-parse/src/ast/expr.rs8
-rw-r--r--crates/rebel-parse/src/grammar/recipe.rs4
4 files changed, 10 insertions, 10 deletions
diff --git a/crates/rebel-lang/src/typing.rs b/crates/rebel-lang/src/typing.rs
index 7eaa5d8..7b20517 100644
--- a/crates/rebel-lang/src/typing.rs
+++ b/crates/rebel-lang/src/typing.rs
@@ -331,8 +331,8 @@ impl Type {
Literal::Struct(entries) => Struct(
entries
.iter()
- .map(|expr::StructField { key, value }| {
- Ok(((*key).to_owned(), Self::ast_expr_type(ctx, value)?))
+ .map(|expr::StructField { name, value }| {
+ Ok(((*name).to_owned(), Self::ast_expr_type(ctx, value)?))
})
.collect::<Result<_>>()?,
),
diff --git a/crates/rebel-lang/src/value.rs b/crates/rebel-lang/src/value.rs
index 616f393..fe1d10c 100644
--- a/crates/rebel-lang/src/value.rs
+++ b/crates/rebel-lang/src/value.rs
@@ -287,8 +287,8 @@ impl Value {
Literal::Struct(entries) => Struct(
entries
.iter()
- .map(|expr::StructField { key, value }| {
- Ok(((*key).to_owned(), Self::eval(ctx, value)?))
+ .map(|expr::StructField { name, value }| {
+ Ok(((*name).to_owned(), Self::eval(ctx, value)?))
})
.collect::<Result<_>>()?,
),
diff --git a/crates/rebel-parse/src/ast/expr.rs b/crates/rebel-parse/src/ast/expr.rs
index 6899903..69c4407 100644
--- a/crates/rebel-parse/src/ast/expr.rs
+++ b/crates/rebel-parse/src/ast/expr.rs
@@ -200,9 +200,9 @@ impl<'a> Literal<'a> {
Ok(())
}
Literal::Struct(entries) => {
- let mut keys = HashSet::new();
- for StructField { key, value } in entries {
- if !keys.insert(key) {
+ let mut fields = HashSet::new();
+ for StructField { name, value } in entries {
+ if !fields.insert(name) {
return Err(ValidationError::DuplicateKey);
}
value.validate()?;
@@ -238,7 +238,7 @@ impl<'a> TryFrom<&token::StrPiece<'a>> for StrPiece<'a> {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StructField<'a> {
- pub key: &'a str,
+ pub name: &'a str,
pub value: Expr<'a>,
}
diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs
index 64c7acd..c0c0ccf 100644
--- a/crates/rebel-parse/src/grammar/recipe.rs
+++ b/crates/rebel-parse/src/grammar/recipe.rs
@@ -123,8 +123,8 @@ peg::parser! {
}
rule struct_field() -> expr::StructField<'a>
- = key:field() p('=') value:expr() {
- expr::StructField { key: key.name, value }
+ = field:field() p('=') value:expr() {
+ expr::StructField { name: field.name, value }
}
rule path() -> ast::Path<'a>