#vec #bounded #non-empty

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

#119 in Rust patterns

Download history 11447/week @ 2023-08-16 22074/week @ 2023-08-23 30718/week @ 2023-08-30 27587/week @ 2023-09-06 26318/week @ 2023-09-13 20653/week @ 2023-09-20 20723/week @ 2023-09-27 19450/week @ 2023-10-04 22956/week @ 2023-10-11 26167/week @ 2023-10-18 28915/week @ 2023-10-25 32295/week @ 2023-11-01 29444/week @ 2023-11-08 32268/week @ 2023-11-15 35927/week @ 2023-11-22 25812/week @ 2023-11-29

129,010 downloads per month
Used in 99 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