array-concat

Crates.ioarray-concat
lib.rsarray-concat
version0.5.3
sourcesrc
created_at2021-04-15 16:56:21.341352
updated_at2024-06-01 05:15:57.532301
descriptionMacros for concatenating const arrays.
homepage
repositoryhttps://github.com/inspier/array-concat
max_upload_size
id384895
size7,866
(inspier)

documentation

README

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);
}
Commit count: 32

cargo fmt