2 releases

0.1.1 Apr 8, 2022
0.1.0 Apr 8, 2022

#2989 in Rust patterns

Download history 218/week @ 2024-07-20 298/week @ 2024-07-27 287/week @ 2024-08-03 296/week @ 2024-08-10 182/week @ 2024-08-17 399/week @ 2024-08-24 98/week @ 2024-08-31 91/week @ 2024-09-07 85/week @ 2024-09-14 98/week @ 2024-09-21 308/week @ 2024-09-28 74/week @ 2024-10-05 219/week @ 2024-10-12 82/week @ 2024-10-19 64/week @ 2024-10-26 83/week @ 2024-11-02

456 downloads per month
Used in spcasm

Zlib license

27KB
590 lines

Rust crates-io api-docs

Array concatenation

This crate allows concatenating multiple arrays of varying lengths into one array.

Example

concat_arrays

For more examples of using concat_arrays, you can look here.

use arrcat::concat_arrays;

{
    const PRIMES: [u16; 4] = [7, 11, 13, 17];
    assert_eq!(
        concat_arrays!([3, 4, 4u16.pow(3)], PRIMES),
        [3, 4, 64, 7, 11, 13, 17],
    );
}

{

    let increasing = [8, 9, 10];

    let concated = concat_arrays!(
        // the macro can't infer the length of runtime array non-literals.
        increasing: [_; 3],
        // most non-literal arguments need to be wrapped in `()` or `{}`.
        ([2u16, 3, 4].map(|x| x * 9)): [_; 3],
    );

    assert_eq!(concated, [8, 9, 10, 18, 27, 36]);
}

No-std support

arrcat is #![no_std], it can be used anywhere Rust can be used.

Minimum Supported Rust Version

arrcat requires Rust 1.57.0, requiring crate features to use newer language features.

No runtime deps