bounded-vec

Crates.iobounded-vec
lib.rsbounded-vec
version0.7.1
sourcesrc
created_at2021-05-10 15:36:00.852117
updated_at2022-08-01 13:27:10.912345
descriptionNon-empty rust Vec wrapper with type guarantees on lower and upper bounds for items quantity.
homepage
repositoryhttps://github.com/ergoplatform/bounded-vec
max_upload_size
id395620
size35,826
Ross Weir (ross-weir)

documentation

README

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.

Commit count: 59

cargo fmt