#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

#183 in Data structures

Download history 4556/week @ 2024-08-14 5024/week @ 2024-08-21 3844/week @ 2024-08-28 4648/week @ 2024-09-04 4213/week @ 2024-09-11 4059/week @ 2024-09-18 3791/week @ 2024-09-25 4385/week @ 2024-10-02 3468/week @ 2024-10-09 3898/week @ 2024-10-16 4096/week @ 2024-10-23 3926/week @ 2024-10-30 3888/week @ 2024-11-06 4741/week @ 2024-11-13 3259/week @ 2024-11-20 1830/week @ 2024-11-27

14,329 downloads per month
Used in 16 crates (9 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