Macro hcl::structure

source ·
macro_rules! structure {
    ($($structure:tt)+) => { ... };
}
Expand description

Construct an hcl::Structure which may be either an HCL attribute or block.

For supported syntax see the body! macro documentation.

§Example

use hcl::{Attribute, Block, Structure};

assert_eq!(
    hcl::structure!(foo = "bar"),
    Structure::Attribute(Attribute::new("foo", "bar")),
);

assert_eq!(
    hcl::structure!(
        resource "aws_s3_bucket" "bucket" {
            name = "the-bucket"
        }
    ),
    Structure::Block(
        Block::builder("resource")
            .add_labels(["aws_s3_bucket", "bucket"])
            .add_attribute(("name", "the-bucket"))
            .build()
    ),
);