2 stable releases

1.0.1 Jul 31, 2023
1.0.0 Oct 3, 2022

#2892 in Rust patterns

Download history 47/week @ 2025-09-25 46/week @ 2025-10-02 42/week @ 2025-10-09 101/week @ 2025-10-16 58/week @ 2025-10-23 33/week @ 2025-10-30 136/week @ 2025-11-06 53/week @ 2025-11-13 158/week @ 2025-11-20 58/week @ 2025-11-27 23/week @ 2025-12-04 12/week @ 2025-12-11 23/week @ 2025-12-18 19/week @ 2025-12-25 26/week @ 2026-01-01 2/week @ 2026-01-08

72 downloads per month
Used in 5 crates

MIT license

3KB

License Cargo Documentation

Assert is used to create generic trait bounds:

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

use const_assert::{Assert, IsTrue, IsFalse};

struct Buffer<const N: usize> {
  inner: [usize; N],
}

impl<const N: usize> Buffer<N>
where
  Assert<{ N == N.next_power_of_two() }>: IsTrue,
  Assert<{ N == 1 }>: IsFalse
{
  pub const fn new() -> Self {
      Buffer { inner: [0; N] }
  }
}

static BUFFER: Buffer<1024> = Buffer::new();

No runtime deps