sort-const 1.0.1

Sort arrays and slices in const contexts.
Documentation
  • Coverage
  • 83.33%
    5 out of 6 items documented3 out of 5 items with examples
  • Size
  • Source code size: 19.19 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 315.73 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Daniel-Aaron-Bloom/sort-const-rs
    3 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Daniel-Aaron-Bloom

sort-const

Crates.io Workflow Status

A macro for sorting arrays and slices at compile time.

Usage

Just use the const_quicksort or const_shellsort macros.

use sort_const::const_quicksort;

const fn lt(a: &u8, b: &u8) -> bool {
    *a < *b
}

const A: &[u8] = &const_quicksort!([3, 1, 2]);
const B: &[u8] = &const_quicksort!([3, 1, 2], |a, b| *a < *b);
const C: &[u8] = &const_quicksort!([3, 1, 2], lt);

assert_eq!(A, [1, 2, 3]);
assert_eq!(B, [1, 2, 3]);
assert_eq!(C, [1, 2, 3]);

For now, this crate uses a custom consty fork of arrayvec. bluss/arrayvec#294 should fix this.

License

Licensed under