#fixed-size #array #dynamic #freely #dynamically-allocated #dereferenced

dynamic-array

A dynamically-allocated array of fixed size

12 releases

0.2.3 Oct 31, 2021
0.2.2 Oct 30, 2021
0.2.1 Aug 18, 2021
0.1.5 Aug 15, 2021
0.0.1 Nov 3, 2020

#3 in #freely

Download history 42/week @ 2024-07-22 46/week @ 2024-07-29 16/week @ 2024-08-05 11/week @ 2024-08-12 8/week @ 2024-08-19 7/week @ 2024-08-26 32/week @ 2024-09-02 46/week @ 2024-09-09 118/week @ 2024-09-16 64/week @ 2024-09-23 15/week @ 2024-09-30 120/week @ 2024-10-07 152/week @ 2024-10-14 32/week @ 2024-10-21 119/week @ 2024-10-28 118/week @ 2024-11-04

435 downloads per month

MIT/Apache

17KB
380 lines

dynamic-array

A dynamically-allocated array of fixed size.

use dynamic_array::SmallArray;

let mut arr = SmallArray::<u32>::zeroed(9);

assert!(!arr.is_empty());

// can be freely dereferenced
assert_eq!(arr[3], 0);

arr[7] = 8;

assert_eq!(arr[7], 8);

let mut arr2 = arr.clone();

assert_ne!(arr2[3],4);
arr[2] = 4;
arr2[3] = 4;
assert_eq!(arr[2],4);
assert_eq!(arr2[3],4);

// can also be freely iterated
for x in arr.iter_mut() {
    *x += 1;
}

assert_eq!(arr[2], 5);

Dependencies

~0–500KB
~12K SLoC