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
//! Proc Macros for the rlst library
use TokenStream;
/// Allocate a dynamic column-major RLST array.
///
/// Syntax is `rlst_dynamic_array!(ItemType, shape_expression)`. An optional alignment expression
/// follows `|`, as in `rlst_dynamic_array!(f64, [2, 3] | 64)`. The number of dimensions is
/// inferred from the shape array; elements are initialized with `Default`.
///
/// A shape known to have rank zero, such as `[]` or a variable of type `[usize; 0]`,
/// creates a `ZeroDimArray<ItemType>` containing one scalar. Use `scalar()`,
/// `scalar_mut()`, and `into_scalar()` to access it; indexed access is unavailable.
/// Positive ranks produce the existing heap-backed `DynArray` type.
///
/// Dispatch takes place where the macro expands. Inside a function generic over
/// the rank, the result remains `DynArray<ItemType, NDIM>` and rank zero is rejected
/// at runtime. Generic reduction code can construct a scalar result explicitly
/// with `ZeroDimArray::from_scalar(value)`.
///
/// For the unaligned form, determine the shape rank through the shape expression
/// or an explicit expected result type. If neither constrains the rank during
/// dispatch, it is inferred as zero; subsequent uses cannot change that choice.
/// For example, annotate `let shape: [usize; 2] = Default::default()` rather than
/// relying on a later use of the resulting array to infer the shape rank.
/// `DynArray::from_shape` retains the original inference behavior for positive ranks.
///
/// # Panics
///
/// Panics if an alignment is requested for rank zero, or if an unresolved generic
/// rank is instantiated with zero.
/// Create a stack-backed column-major RLST array.
///
/// Syntax is `rlst_static_array!(ItemType, [literal_dimension, ...])`. Dimensions must be integer
/// literals because their product determines the backing Rust array type at compile time.
/// Expand to the type of a stack-backed RLST array.
///
/// Syntax is `rlst_static_type!(ItemType, literal_dimension, ...)`, without brackets around the
/// dimensions. At least one dimension is required.
/// Instrument a function with entry, exit, and elapsed-time log messages.
///
/// The attribute takes no arguments. Its expansion calls `rlst::rlst_print!`, which emits log
/// records when RLST's `enable_tracing` feature is enabled and otherwise compiles to a no-op.