bounded_vector/
lib.rs

1#![warn(missing_docs)]
2
3//! [`BoundedVec<T, LOW, UPP>`] - Vec wrapper that guarantees upper and lower bounds on type level.
4//! Alternative to [bounded-vec](https://github.com/ergoplatform/bounded-vec) that offers compatibility with empty vector, has more methods and [`bvec!`] that works like vec! macro.
5//!
6//! Example
7//! ```rust
8//! # use std::error::Error;
9//! #
10//! # fn main() -> Result<(), Box<dyn Error>> {
11//! use bounded_vector::{BoundedVec, bvec};
12//! let mut data: BoundedVec<u8, 2, 4> = [1, 2].try_into()?;
13//!
14//! assert_eq!(data.first(), Some(&1));
15//! assert_eq!(data.last(), Some(&2));
16//!
17//! data.iter_mut().for_each(|x| *x *= 2);
18//! assert_eq!(data, bvec![2, 4]);
19//! #     Ok(())
20//! # }
21//! ```
22
23mod bounded_vec;
24mod macros;
25pub use bounded_vec::{BoundedVec, Error};
26#[cfg(feature = "serde")]
27mod serde;