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
//! Macros for creating boxed slices and arrays.
// TODO: We might be able to make these more performant by using `MaybeUninit`.
/// Macro to create a boxed slice (`Box<[T]>`).
///
/// Similar to standard library's `vec!` macro.
///
/// If length is a const (known at compile time), you would likely be better off using a boxed array instead
/// (`boxed_array!` macro).
///
/// # Example
/// ```
/// # fn get_length_somehow() -> usize { 5 }
///
/// use oxc_data_structures::box_macros::boxed_slice;
///
/// let len = get_length_somehow();
/// // Creates a `Box<[u64]>`
/// let boxed = boxed_slice![0u64; len];
/// ```
pub use boxed_slice;
/// Macro to create a boxed array (`Box<[T; N]>`).
///
/// Similar to standard library's `vec!` macro.
///
/// `$len` must be a const expression.
///
/// # Example
/// ```
/// use oxc_data_structures::box_macros::boxed_array;
///
/// const LENGTH: usize = 5;
/// // Creates a `Box<[u64; LENGTH]>`
/// let boxed = boxed_array![0u64; LENGTH];
/// ```
pub use boxed_array;