Skip to content

Commit 41d90d7

Browse files
Fix ColsRef macro spec
1 parent 4e2dcdf commit 41d90d7

File tree

1 file changed

+2
-1
lines changed
  • crates/circuits/primitives/derive/src/cols_ref

1 file changed

+2
-1
lines changed

crates/circuits/primitives/derive/src/cols_ref/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct ExampleCols<T, const N: usize> {
4444
which will generate a columns struct that uses references to the fields.
4545
```rust
4646
struct ExampleColsRef<'a, T, const N: usize> {
47-
arr: &'a [T; N],
47+
arr: ndarray::ArrayView1<'a, T>, // an n-dimensional view into the input slice (ArrayView2 for 2D arrays, etc.)
4848
sum: &'a T,
4949
}
5050
```
@@ -89,6 +89,7 @@ The fields of `ExampleColsRef` have the same names as the fields of `ExampleCols
8989
- fields with names that end in `Cols` are assumed to be a columns struct that derives `ColsRef` and are transformed into the appropriate `ColsRef` type recursively
9090
- one restriction is that any nested `ColsRef` type must have the same config as the outer `ColsRef` type
9191
- fields that are annotated with `#[aligned_borrow]` are assumed to derive `AlignedBorrow` and are borrowed from the input slice. The new type is a reference to the `AlignedBorrow` type
92+
- if a field whose name ends in `Cols` is annotated with `#[aligned_borrow]`, then the aligned borrow takes precedence, and the field is not transformed into an `ArrayView`
9293
- nested arrays of `U` become `&ArrayViewX<U>` where `X` is the number of dimensions in the nested array type
9394
- `U` can be either the generic type `T` or a type that derives `AlignedBorrow`. In the latter case, the field must be annotated with `#[aligned_borrow]`
9495
- the `ArrayViewX` type provides a `X`-dimensional view into the row slice

0 commit comments

Comments
 (0)