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