template_ref

Macro template_ref 

Source
macro_rules! template_ref {
    ($template:literal, dependencies = [$($dep:literal),* $(,)?]) => { ... };
    ($template:literal) => { ... };
}
Expand description

Create a template reference with dependencies at compile time.

This macro creates a TronRef from a template string and a list of dependencies. Both template syntax and dependency format are validated at compile time.

§Examples

use tron::template_ref;

let template_ref = template_ref!(
    "use serde::Serialize;\n#[derive(Serialize)]\nstruct @[name]@ { @[fields]@ }",
    dependencies = ["serde = \"1.0\""]
);

§With Multiple Dependencies

use tron::template_ref;

let template_ref = template_ref!(
    "async fn @[name]@() -> Result<@[return_type]@, @[error_type]@> { @[body]@ }",
    dependencies = [
        "tokio = \"1.0\"",
        "serde = \"1.0\"",
        "anyhow = \"1.0\""
    ]
);