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
149,549 downloads per month
Used in 81 crates
(8 directly)
22KB
361 lines
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 toBoundedVec
. - optional(non-default)
arbitrary
feature that addsproptest::Arbitrary
implementation toBoundedVec
.
Changelog
See CHANGELOG.md.
Contributing
See Contributing guide.
Dependencies
~0.2–1.3MB
~26K SLoC