3 releases

Uses new Rust 2024

new 0.1.2 Mar 21, 2025
0.1.1 Mar 17, 2025
0.1.0 Mar 16, 2025

#440 in Rust patterns

Download history 194/week @ 2025-03-12

194 downloads per month

MIT license

84KB
2K SLoC

maxlen

crates.io docs.rs

Length-bounded wrappers over standard types.

This crate provides several types that enforce length limits at the type level:

  • BSlice<T, MAX> is a [T] but guaranteed to not have more than MAX elements.
  • BVec<T, MAX> is a Vec<T> but guaranteed to not have more than MAX elements.
  • BStr<MAX, E> is a str but guarantees that the text will not be longer than MAX bytes in the specified encoding (not necessarily UTF-8).
  • BString<MAX, E> is a String but guarantees that the text will not be longer than MAX bytes in the specified encoding (not necessarily UTF-8).

Dependencies

~270–730KB
~16K SLoC