Introducing a KVPair type
This commit is contained in:
parent
dd8b4ac28c
commit
79100fc50f
@ -119,6 +119,12 @@ enum RValue<'a> {
|
|||||||
RVLiteral(&'a str),
|
RVLiteral(&'a str),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
struct KVPair<'a> {
|
||||||
|
key: &'a str,
|
||||||
|
value: RValue<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
/// Any element significant to dust that isn't plain text
|
/// Any element significant to dust that isn't plain text
|
||||||
///
|
///
|
||||||
/// These elements are always wrapped in curly braces
|
/// These elements are always wrapped in curly braces
|
||||||
@ -179,8 +185,11 @@ fn rvalue(i: &str) -> IResult<&str, RValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parameters for a partial
|
/// Parameters for a partial
|
||||||
fn key_value_pair(i: &str) -> IResult<&str, (&str, RValue)> {
|
fn key_value_pair(i: &str) -> IResult<&str, KVPair> {
|
||||||
separated_pair(key, tag("="), rvalue)(i)
|
map(separated_pair(key, tag("="), rvalue), |(k, v)| KVPair {
|
||||||
|
key: k,
|
||||||
|
value: v,
|
||||||
|
})(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display a value from the context
|
/// Display a value from the context
|
||||||
@ -692,7 +701,10 @@ mod tests {
|
|||||||
"",
|
"",
|
||||||
(
|
(
|
||||||
"foo",
|
"foo",
|
||||||
Some(vec![("bar", RValue::RVPath(Path { keys: vec!["baz"] }))])
|
Some(vec![KVPair {
|
||||||
|
key: "bar",
|
||||||
|
value: RValue::RVPath(Path { keys: vec!["baz"] })
|
||||||
|
}])
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user