#upper-bound #vec #bounded #non-empty #bounds #lower #guarantees

bounded-vec

Non-empty rust Vec wrapper with type guarantees on lower and upper bounds for items quantity

9 releases (breaking)

0.8.0 Dec 2, 2024
0.7.1 Aug 1, 2022
0.7.0 Jul 26, 2022
0.5.0 Oct 14, 2021
0.3.0 Jun 9, 2021

#96 in Data structures

Download history 40195/week @ 2024-10-22 36044/week @ 2024-10-29 44699/week @ 2024-11-05 35768/week @ 2024-11-12 34833/week @ 2024-11-19 33806/week @ 2024-11-26 34280/week @ 2024-12-03 35039/week @ 2024-12-10 26903/week @ 2024-12-17 10386/week @ 2024-12-24 18027/week @ 2024-12-31 30562/week @ 2025-01-07 45978/week @ 2025-01-14 36109/week @ 2025-01-21 31851/week @ 2025-01-28 30183/week @ 2025-02-04

150,950 downloads per month
Used in 96 crates (8 directly)

CC0 license

22KB
365 lines

Coverage Status Latest Version Documentation

bounded-vec

BoundedVec<T, L, U> - Non-empty rust std::vec::Vec wrapper with type guarantees on lower(L) and upper(U) bounds for items quantity. Inspired by vec1.

Example

use bounded_vec::BoundedVec;

let data: BoundedVec<u8, 2, 4> = [1u8,2].into();

assert_eq!(*data.first(), 1);
assert_eq!(*data.last(), 2);

// creates a new BoundedVec by mapping each element
let data = data.mapped(|x|x*2);
assert_eq!(data, [2u8,4].into());

Crate features

  • optional(non-default) serde feature that adds serialization to BoundedVec.
  • optional(non-default) arbitrary feature that adds proptest::Arbitrary implementation to BoundedVec.

Changelog

See CHANGELOG.md.

Contributing

See Contributing guide.

Dependencies

~0.2–1.2MB
~24K SLoC