stmt_block_from_vec

Macro stmt_block_from_vec 

Source
macro_rules! stmt_block_from_vec {
    ($stmts:expr) => { ... };
}
Expand description

Converts a Vec<Stmt> into a single block statement for use in ts_quote!.

This macro is useful when you need to interpolate multiple statements in a context where only a single statement is expected. The statements are wrapped in a block { ... }.

This is an alias for stmt_block! and behaves identically.

ยงExamples

use macroforge_ts_syn::{stmt_block_from_vec, quote};
use swc_core::ecma::ast::Stmt;

fn generate_body() -> Vec<Stmt> {
    // Generate multiple statements
    vec![]
}

let body_block = stmt_block_from_vec!(generate_body());
// Can now use body_block where a single Stmt is expected