| Crates.io | bounded-vec |
| lib.rs | bounded-vec |
| version | 0.9.0 |
| created_at | 2021-05-10 15:36:00.852117+00 |
| updated_at | 2025-06-05 14:25:25.748298+00 |
| 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 | 58,553 |
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.
This crate is #![no_std] compatible with alloc.
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());
BoundedVec.schema feature that adds JSON schema support via schemars (requires serde).arbitrary feature that adds proptest::Arbitrary implementation to BoundedVec.See CHANGELOG.md.
See Contributing guide.