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

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

#136 in Data structures

Download history 27884/week @ 2024-06-03 22255/week @ 2024-06-10 24025/week @ 2024-06-17 28897/week @ 2024-06-24 26144/week @ 2024-07-01 24536/week @ 2024-07-08 31054/week @ 2024-07-15 32922/week @ 2024-07-22 27248/week @ 2024-07-29 31796/week @ 2024-08-05 43490/week @ 2024-08-12 27253/week @ 2024-08-19 37076/week @ 2024-08-26 42762/week @ 2024-09-02 35906/week @ 2024-09-09 33041/week @ 2024-09-16

149,549 downloads per month
Used in 81 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.2–1.3MB
~26K SLoC