#array #concat #macro #const #concatenating

no-std array-concat

Macros for concatenating const arrays

11 unstable releases

0.5.3 Jun 1, 2024
0.5.2 Jan 27, 2023
0.5.1 Jun 3, 2021

#365 in Data structures

Download history 2985/week @ 2024-06-10 2817/week @ 2024-06-17 3249/week @ 2024-06-24 2055/week @ 2024-07-01 3339/week @ 2024-07-08 3308/week @ 2024-07-15 3461/week @ 2024-07-22 4728/week @ 2024-07-29 4735/week @ 2024-08-05 4637/week @ 2024-08-12 5102/week @ 2024-08-19 4489/week @ 2024-08-26 4411/week @ 2024-09-02 3583/week @ 2024-09-09 4525/week @ 2024-09-16 3817/week @ 2024-09-23

16,522 downloads per month
Used in 10 crates (7 directly)

MIT license

7KB
89 lines

Current Crates.io Version docs-rs

array-concat

Macros for concatenating arrays.

To add to your Cargo.toml:

array-concat = "0.5.3"

Example

use array_concat::*;

const A: [u32; 3] = [1, 2, 3];
const B: [u32; 2] = [4, 5];
const C: [u32; concat_arrays_size!(A, B)] = concat_arrays!(A, B);

// Non-Copy struct
#[derive(Debug, PartialEq)]
struct S(bool);
const D: [S; 1] = [S(true)];
const E: [S; 1] = [S(false)];
const F: [S; concat_arrays_size!(D, E)] = concat_arrays!(D, E);

fn main() {
    let c = concat_arrays!(A, B);
    assert_eq!([1, 2, 3, 4, 5], C);
    assert_eq!([1, 2, 3, 4, 5], c);
    assert_eq!([S(true), S(false)], F);

    let a = [1, 2, 3];
    let b = [4, 5];
    let c = concat_arrays!(a, b); // Size is inferred by the assert below
    assert_eq!([1, 2, 3, 4, 5], c);
}

No runtime deps

Features