Crates.io | bounded-vec |
lib.rs | bounded-vec |
version | 0.7.1 |
source | src |
created_at | 2021-05-10 15:36:00.852117 |
updated_at | 2022-08-01 13:27:10.912345 |
description | Non-empty rust Vec wrapper with type guarantees on lower and upper bounds for items quantity. |
homepage | |
repository | https://github.com/ergoplatform/bounded-vec |
max_upload_size | |
id | 395620 |
size | 35,826 |
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());
serde
feature that adds serialization to BoundedVec
.arbitrary
feature that adds proptest::Arbitrary
implementation to BoundedVec
.See CHANGELOG.md.
See Contributing guide.