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

bounded-vec

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

8 releases (breaking)

0.7.1 Aug 1, 2022
0.7.0 Jul 26, 2022
0.6.0 Apr 21, 2022
0.5.0 Oct 14, 2021
0.1.0 May 10, 2021

#87 in Data structures

Download history 20592/week @ 2024-01-05 23704/week @ 2024-01-12 26589/week @ 2024-01-19 25535/week @ 2024-01-26 23255/week @ 2024-02-02 24382/week @ 2024-02-09 31441/week @ 2024-02-16 31034/week @ 2024-02-23 25065/week @ 2024-03-01 25395/week @ 2024-03-08 25882/week @ 2024-03-15 28479/week @ 2024-03-22 33192/week @ 2024-03-29 35718/week @ 2024-04-05 33593/week @ 2024-04-12 24176/week @ 2024-04-19

131,084 downloads per month
Used in 80 crates (8 directly)

CC0 license

22KB
361 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.4–1.3MB
~29K SLoC