#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

#95 in Data structures

Download history 33757/week @ 2024-09-26 43072/week @ 2024-10-03 40911/week @ 2024-10-10 39615/week @ 2024-10-17 40019/week @ 2024-10-24 42838/week @ 2024-10-31 37353/week @ 2024-11-07 35580/week @ 2024-11-14 34557/week @ 2024-11-21 32244/week @ 2024-11-28 36975/week @ 2024-12-05 33983/week @ 2024-12-12 15506/week @ 2024-12-19 10285/week @ 2024-12-26 28403/week @ 2025-01-02 27110/week @ 2025-01-09

90,152 downloads per month
Used in 90 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.3–1.2MB
~26K SLoC