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.
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());
- optional(non-default)
serde
feature that adds serialization toBoundedVec
. - optional(non-default)
arbitrary
feature that addsproptest::Arbitrary
implementation toBoundedVec
.
See CHANGELOG.md.
See Contributing guide.