#type-level #hlist #typenum

no-std sorted-hlist

Type-level heterogeneous lists with compile-time intersection and sorting using typenum

3 unstable releases

0.2.0 Apr 28, 2025
0.1.1 Apr 27, 2025
0.1.0 Apr 26, 2025

#866 in Embedded development

Download history 99/week @ 2025-08-15 157/week @ 2025-08-22 143/week @ 2025-08-29 56/week @ 2025-09-05 125/week @ 2025-09-12 116/week @ 2025-09-19 273/week @ 2025-09-26 80/week @ 2025-10-03 364/week @ 2025-10-10 136/week @ 2025-10-17 226/week @ 2025-10-24 106/week @ 2025-10-31 386/week @ 2025-11-07 596/week @ 2025-11-14 336/week @ 2025-11-21 503/week @ 2025-11-28

1,834 downloads per month
Used in 11 crates (via atsamd-hal)

MIT/Apache

9KB
78 lines

sorted-hlist

A zero-cost, type-level heterogeneous list (HList) implementation in Rust with support for compile-time sorting constraints and intersection operations - powered by typenum.

Features

  • Type-level HLists: HCons and HNil
  • Compile-time enforcement of sortedness (SortedHList)
  • Type-level set intersection via the Intersect trait
  • Type-safe macro mk_hlist!(...) for building HLists
  • No runtime overhead - all type-level logic only

Example

use sorted_hlist::{mk_hlist, Intersect};
use typenum::{U1, U2, U3, U4};

// Create type-level HLists
type A = mk_hlist!(U1, U2, U3);
type B = mk_hlist!(U2, U3, U4);

// Compute intersection
type Common = <A as Intersect<B>>::Output;

// Common = mk_hlist!(U2, U3)

Crate Goals

  • Use in embedded HALs or systems programming where traits and sets represent hardware capabilities
  • Keep things fast, predictable, and compile-time checked
  • No dependencies other than typenum

License

Licensed under either of:

Contribution

Pull requests, suggestions and improvements welcome!

Dependencies

~450KB
~12K SLoC