1 unstable release

0.1.2 May 9, 2021
0.1.1 May 8, 2021
0.1.0 May 8, 2021

#612 in Procedural macros

Download history 2731/week @ 2023-12-14 2270/week @ 2023-12-21 2256/week @ 2023-12-28 2278/week @ 2024-01-04 2701/week @ 2024-01-11 2624/week @ 2024-01-18 2660/week @ 2024-01-25 2269/week @ 2024-02-01 3239/week @ 2024-02-08 3021/week @ 2024-02-15 2482/week @ 2024-02-22 2253/week @ 2024-02-29 2437/week @ 2024-03-07 2896/week @ 2024-03-14 3373/week @ 2024-03-21 2506/week @ 2024-03-28

11,575 downloads per month
Used in 13 crates (6 directly)

LGPL-2.0

7KB
102 lines

concat-arrays: a rust macro for concatenating fixed-size arrays

This crate defines concat_arrays!, a macro that allows you to concatenate arrays.

Example:

use concat_arrays::concat_arrays;

fn main() {
    let x = [0];
    let y = [1, 2];
    let z = [3, 4, 5];
    let concatenated = concat_arrays!(x, y, z);
    assert_eq!(concatenated, [0, 1, 2, 3, 4, 5]);
}

Limitations

Due to limitations in rust concat_arrays! can't tell the compiler what the length of the returned array is. As such, the length needs to be inferable from the surrounding context. For example, in the example above the length is inferred by the call to assert_eq!. It is safe to mis-specify the length however since you'll get a compilation error rather than broken code.

Credits

Inspiration for how to implement this was taken largely from the const-concat crate (which implements compile-time array concatenation).

Dependencies

~1.5MB
~34K SLoC