Macro hcl::expression
source · [−]macro_rules! expression {
($($expr:tt)+) => { ... };
}Expand description
Construct an hcl::Expression from an HCL attribute value expression literal.
For supported syntax see the body! macro documentation.
Examples
use hcl::{Expression, Object, ObjectKey};
let other = "hello";
let expression = hcl::expression!({
foo = true
"baz qux" = [1, 2]
(other) = "world"
});
let expected = Expression::Object({
let mut object = Object::new();
object.insert(ObjectKey::identifier("foo"), true.into());
object.insert(ObjectKey::string("baz qux"), vec![1u64, 2].into());
object.insert(ObjectKey::string("hello"), "world".into());
object
});
assert_eq!(expression, expected);