Debian Codegraph @

debian/rust-vendor/arrayvec/src/lib.rs

raw
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")]
26 extern crate serde;
27
28 #[cfg(not(feature="std"))]
29 extern crate core as std;
30
31 #[cfg(not(target_pointer_width = "16"))]
32 pub(crate) type LenUint = u32;
33
34 #[cfg(target_pointer_width = "16")]
35 pub(crate) type LenUint = u16;
36
37 macro_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
50 macro_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
60 mod arrayvec_impl;
61 mod arrayvec;
62 mod array_string;
63 mod char;
64 mod errors;
65 mod utils;
66
67 pub use crate::array_string::ArrayString;
68 pub use crate::errors::CapacityError;
69
70 pub use crate::arrayvec::{ArrayVec, IntoIter, Drain};