#vec #bounded #non-empty #quantity #bounds #wrapper #upper-bounds

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

#124 in Data structures

Download history 6733/week @ 2022-08-19 6898/week @ 2022-08-26 7900/week @ 2022-09-02 6996/week @ 2022-09-09 7426/week @ 2022-09-16 6112/week @ 2022-09-23 8134/week @ 2022-09-30 7864/week @ 2022-10-07 8136/week @ 2022-10-14 6005/week @ 2022-10-21 6352/week @ 2022-10-28 8446/week @ 2022-11-04 7596/week @ 2022-11-11 7049/week @ 2022-11-18 7300/week @ 2022-11-25 7501/week @ 2022-12-02

30,880 downloads per month
Used in 18 crates (7 directly)

CC0 license

21KB
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.2–1MB
~22K SLoC