Skip to main content

arrayvec/
lib.rs

1//! **arrayvec** provides the types [`ArrayVec`] and [`ArrayString`]: 
2//! array-backed vector and string types, which store their contents inline.
3//!
4//! The arrayvec package has the following cargo features:
5//!
6//! - `std`
7//!   - Optional, enabled by default
8//!   - Use libstd; disable to use `no_std` instead.
9//!
10//! - `serde`
11//!   - Optional
12//!   - Enable serialization for ArrayVec and ArrayString using serde 1.x
13//!
14//! - `zeroize`
15//!   - Optional
16//!   - Implement `Zeroize` for ArrayVec and ArrayString
17//!
18//! ## Rust Version
19//!
20//! This version of arrayvec requires Rust 1.51 or later.
21//!
22#![doc(html_root_url="https://docs.rs/arrayvec/0.7/")]
23#![cfg_attr(not(feature="std"), no_std)]
24
25#[cfg(feature="serde")]
26extern crate serde;
27
28#[cfg(not(feature="std"))]
29extern crate core as std;
30
31#[cfg(not(target_pointer_width = "16"))]
32pub(crate) type LenUint = u32;
33
34#[cfg(target_pointer_width = "16")]
35pub(crate) type LenUint = u16;
36
37macro_rules! assert_capacity_limit {
38    ($cap:expr) => {
39        if std::mem::size_of::<usize>() > std::mem::size_of::<LenUint>() {
40            if $cap > LenUint::MAX as usize {
41                #[cfg(not(target_pointer_width = "16"))]
42                panic!("ArrayVec: largest supported capacity is u32::MAX");
43                #[cfg(target_pointer_width = "16")]
44                panic!("ArrayVec: largest supported capacity is u16::MAX");
45            }
46        }
47    }
48}
49
50macro_rules! assert_capacity_limit_const {
51    ($cap:expr) => {
52        if std::mem::size_of::<usize>() > std::mem::size_of::<LenUint>() {
53            if $cap > LenUint::MAX as usize {
54                [/*ArrayVec: largest supported capacity is u32::MAX*/][$cap]
55            }
56        }
57    }
58}
59
60mod arrayvec_impl;
61mod arrayvec;
62mod array_string;
63mod char;
64mod errors;
65mod utils;
66
67pub use crate::array_string::ArrayString;
68pub use crate::errors::CapacityError;
69
70pub use crate::arrayvec::{ArrayVec, IntoIter, Drain};