#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

#92 in Data structures

Download history 24519/week @ 2023-12-13 17085/week @ 2023-12-20 9278/week @ 2023-12-27 18614/week @ 2024-01-03 22046/week @ 2024-01-10 27356/week @ 2024-01-17 26401/week @ 2024-01-24 20861/week @ 2024-01-31 25872/week @ 2024-02-07 29279/week @ 2024-02-14 29406/week @ 2024-02-21 28349/week @ 2024-02-28 24469/week @ 2024-03-06 24601/week @ 2024-03-13 30439/week @ 2024-03-20 20215/week @ 2024-03-27

104,266 downloads per month
Used in 76 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.3–1.2MB
~27K SLoC