pub fn render_loop<B>(loop_iterations: usize, loop_body: B) -> String
where
    B: core::fmt::Display,
{
    match loop_iterations {
        1 => format!(
            // Indent to match module and function
            r#"
            {LOOP_BODY}
            "#,
            LOOP_BODY = loop_body
        ),
        _ => format!(
            // Indent to match module and function
            r#"
                (loop $loop
                    (if (i32.lt_s (get_local $i) (i32.const {LOOP_ITERATIONS}))
                        (then
                            (set_local $i (i32.add (get_local $i) (i32.const 1)))

                            {LOOP_BODY}

                            (br $loop)
                        )
                    )
                )
        "#,
            LOOP_ITERATIONS = loop_iterations,
            LOOP_BODY = loop_body
        ),
    }
}
/// Return WAT for a simple loop.
Return WAT for a simple loop.
Return WAT for a simple loop .
pub fn render_loop<B>(loop_iterations: usize, loop_body: B) -> String
where
    B: core::fmt::Display,
{
    match loop_iterations {
        1 => format!(
            // Indent to match module and function
            r#"
            {LOOP_BODY}
            "#,
            LOOP_BODY = loop_body
        ),
        _ => format!(
            // Indent to match module and function
            r#"
                (loop $loop
                    (if (i32.lt_s (get_local $i) (i32.const {LOOP_ITERATIONS}))
                        (then
                            (set_local $i (i32.add (get_local $i) (i32.const 1)))
                            {LOOP_BODY}
                            (br $loop)
                        )
                    )
                )
        "#,
            LOOP_ITERATIONS = loop_iterations,
            LOOP_BODY = loop_body
        ),
    }
}
pub fn render_loop < B > ( loop_iterations : usize , loop_body : B ) -> String where B : core :: fmt :: Display , { match loop_iterations { 1 => format ! ( // Indent to match module and function r#"
            {LOOP_BODY}
            "# LOOP_BODY loop_body ) , _ => format ! ( // Indent to match module and function r#"
                (loop $loop
                    (if (i32.lt_s (get_local $i) (i32.const {LOOP_ITERATIONS}))
                        (then
                            (set_local $i (i32.add (get_local $i) (i32.const 1)))

                            {LOOP_BODY}

                            (br $loop)
                        )
                    )
                )
        "# LOOP_ITERATIONS loop_iterations LOOP_BODY loop_body ) , } }
Return WAT for a simple loop.
Return WAT for a simple loop .
loop_iterations
usize
loop_body
B
loop_iterations
usize
loop_body
B