#list #gadt #type-witness #no-std

no-std nlist

inline-allocated list with statically tracked length

5 releases

new 0.0.4 Nov 13, 2024
0.0.3 Nov 13, 2024
0.0.2 Nov 12, 2024
0.0.1 Nov 11, 2024
0.0.0 Nov 11, 2024

#783 in Data structures

Download history 548/week @ 2024-11-09

548 downloads per month

Zlib license

87KB
1.5K SLoC

Provides an inline-allocated list which statically tracks its length.


lib.rs:

Provides an inline-allocated list which statically tracks its length.

Example

use nlist::{NList, Peano, PeanoInt, nlist, peano};

fn transform<T, L>(list: NList<T, L>) -> NList<i128, peano::Add<L, Peano!(1)>>
where
    T: Into<i128>,
    L: PeanoInt,
{
    list.reverse()
        .map(|x| -> i128 { x.into() })
        .map(|x| x * 10)
        .concat(nlist![0])
}

let fibb = transform(nlist![3, 5, 8]);
assert_eq!(fibb.into_vec(), vec![80, 50, 30, 0]);

let powers = transform(nlist![4u8, 9, 25]);
assert_eq!(powers.into_vec(), vec![250, 90, 40, 0]);

Dependencies

~505KB