#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

#377 in Data structures

Download history 2947/week @ 2024-03-14 2797/week @ 2024-03-21 3115/week @ 2024-03-28 3465/week @ 2024-04-04 2835/week @ 2024-04-11 2354/week @ 2024-04-18 2229/week @ 2024-04-25 2429/week @ 2024-05-02 2170/week @ 2024-05-09 2712/week @ 2024-05-16 2248/week @ 2024-05-23 2829/week @ 2024-05-30 2857/week @ 2024-06-06 2935/week @ 2024-06-13 3322/week @ 2024-06-20 2170/week @ 2024-06-27

11,731 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