#heap #heap-allocation #array #error #build #dynamically #push

no-std build-array

Build an array dynamically without heap allocations

3 releases

0.1.2 Jun 26, 2024
0.1.1 Jun 21, 2024
0.1.0 Jun 21, 2024

#222 in Memory management

Download history 5/week @ 2024-07-02 17/week @ 2024-09-24 35/week @ 2024-10-01 65/week @ 2024-10-08 175/week @ 2024-10-15

292 downloads per month

MIT/Apache

10KB
119 lines

Build an array dynamically without heap allocations, deferring errors to a single build callsite.

let arr: [u8; 3] = ArrayBuilder::new()
    .push(1)
    .push(2)
    .push(3)
    .build_exact()
    .unwrap();

assert_eq!(arr, [1, 2, 3]);

You can choose how to handle the wrong number of push calls:

Comparison with other libraries


lib.rs:

Build an array dynamically without heap allocations, deferring errors to a single build callsite.

let arr: [u8; 3] = ArrayBuilder::new()
    .push(1)
    .push(2)
    .push(3)
    .build_exact()
    .unwrap();

assert_eq!(arr, [1, 2, 3]);

You can choose how to handle the wrong number of push calls:

Comparison with other libraries

Dependencies

~69KB