bounded-vector

Crates.iobounded-vector
lib.rsbounded-vector
version0.2.1
sourcesrc
created_at2024-04-11 11:14:24.18593
updated_at2024-04-16 18:59:28.173984
descriptionVec wrapper that guarantees upper and lower bounds on type level.
homepage
repositoryhttps://gitlab.com/fili_pk/bounded-vector
max_upload_size
id1204728
size38,740
(Fili-pk)

documentation

README

bounded-vector

crates.io

BoundedVec<T, LOW, UPP> - Vec wrapper that guarantees upper and lower bounds on type level. Alternative to bounded-vec that offers compatibility with empty vector, has more methods and bvec! that works like vec! macro.

Example

use bounded_vector::{BoundedVec, bvec};
let mut data: BoundedVec<u8, 2, 4> = [1, 2].try_into()?;

assert_eq!(data.first(), Some(1));
assert_eq!(data.last(), Some(2));

data.iter_mut().for_each(|x| *x *= 2);
assert_eq!(data, bvec![2, 4]?);

License

Licensed under either of MIT or Apache-2.0 at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 15

cargo fmt