#seq #repeat #fragment #rhai #expression #super #macro

macro no-std super-seq-macro

Macro to repeat a fragment of code based on a RHAI expression

4 releases

new 0.3.8 Feb 10, 2025
0.3.7 Feb 4, 2025
0.3.6 Feb 4, 2025
0.3.5 Feb 3, 2025

#769 in Development tools

Download history 321/week @ 2025-02-03

321 downloads per month

MIT/Apache

22KB
389 lines

Supercharged seq! macro

github crates.io docs.rs


This crate provides a seq! macro to repeat a fragment of source code and substitute into each repetition a value of your choosing, drawn from an iterable RHAI expression.

This is a fork of the seq-macro crate and is backwards-compatible for simple usage.

use super_seq_macro::seq;

seq!(A in 0..3 {#(
    const WITHOUT_~A: [u32; 2] = seq!(B in (0..3).collect().filter(|x| x != A) {
        [ #( B, )* ]
    });
)*});

assert_eq!(WITHOUT_0, [1, 2]);
assert_eq!(WITHOUT_1, [0, 2]);
assert_eq!(WITHOUT_2, [0, 1]);

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~5.5MB
~98K SLoC