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
A Rust library that allows you to represent the structure as an array.
Library works only with named structs whose fields have the same type.
Basic usage:
```rust
use struct_as_array::*;
struct TestStruct {
}
let t = TestStruct {
};
// Represent as array of reference
assert_eq!(t.as_array(), [&0, &1, &2]);
// Convert struct to array
assert_eq!(t.to_array(), [0, 1, 2]);
```
Using as an iterator:
```rust
use struct_as_array::*;
struct TestStruct {
}
let t = TestStruct {
};
for i in t.as_array() {
}
```