macro_rules! array_str {
($c:expr;) => { ... };
($c:expr; $e:expr) => { ... };
}Available on crate feature
arraystring only.Expand description
Creates an ArrayString containing the arguments.
array_str! macro allows creation of an ArrayString with given capacity and content.
Note that the used length type is Usize and spare memory policy is Uninitialized.
§Examples
array_str![CAPACITY;]- create an emptyArrayStringwith given capacity:
let mut a = array_str![3;];
assert_eq!(a.len(), 0);
assert_eq!(a.capacity(), 3);array_str![CAPACITY; TRY_FROM]- create anArrayStringwith given capacity and initializer:
let a = array_str![32; "Hello, world!"];
assert_eq!(a.capacity(), 32);
assert_eq!(a.len(), 13);
// assert_eq!(a, "Hello, world!");array_str!panics if the number of elements exceeds the requested capacity:
ⓘ
array_str![0; "Hello, world!"];§Panics
The macro panics if initialization of the array-string fails.