macro_rules! array {
() => { ... };
($($val:expr),* $(,)?) => { ... };
}Expand description
Creates an Array containing the given values.
This macro provides a convenient way to create an Array with initial values,
similar to the vec! macro for Vec.
§Examples
// Create an empty array
let empty = array![];
// Create an array with values
let numbers = array![1, 2, 3, 4, 5];
// Trailing commas are allowed
let mixed = array![
"hello",
42,
true,
];§Notes
- Values are automatically converted using
.into(), so they must implement the appropriateIntotrait for the array’s element type. - The capacity is pre-allocated to match the number of elements when known at compile time.