|
2 | 2 | //! automatically generate code from a given struct `T` that allow to replace
|
3 | 3 | //! `Vec<T>` with a struct of arrays. For example, the following code
|
4 | 4 | //!
|
5 |
| -//! ``` |
| 5 | +//! ```ignore |
6 | 6 | //! # #[macro_use] extern crate soa_derive;
|
7 | 7 | //! # fn main() {
|
8 | 8 | //! #[derive(StructOfArray)]
|
|
17 | 17 | //!
|
18 | 18 | //! will generate a `CheeseVec` struct that looks like this:
|
19 | 19 | //!
|
20 |
| -//! ``` |
| 20 | +//! ```ignore |
21 | 21 | //! pub struct CheeseVec {
|
22 | 22 | //! pub smell: Vec<f64>,
|
23 | 23 | //! pub color: Vec<(f64, f64, f64)>,
|
|
38 | 38 | //! (such as `Debug` or `PartialEq`), you can add an attribute `#[soa_derive =
|
39 | 39 | //! "Debug, PartialEq"]` to the struct declaration.
|
40 | 40 | //!
|
41 |
| -//! ``` |
| 41 | +//! ```ignore |
42 | 42 | //! # #[macro_use] extern crate soa_derive;
|
43 | 43 | //! # fn main() {
|
44 | 44 | //! #[derive(Debug, PartialEq, StructOfArray)]
|
|
57 | 57 | //! attribute `#[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]` to the
|
58 | 58 | //! struct declaration.
|
59 | 59 | //!
|
60 |
| -//! ``` |
| 60 | +//! ```ignore |
61 | 61 | //! # #[macro_use] extern crate soa_derive;
|
62 | 62 | //! # fn main() {
|
63 | 63 | //! #[derive(Debug, PartialEq, StructOfArray)]
|
|
108 | 108 | //!
|
109 | 109 | //! It is possible to iterate over the values in a `CheeseVec`
|
110 | 110 | //!
|
111 |
| -//! ```no_run |
| 111 | +//! ```ignore |
112 | 112 | //! # #[macro_use] extern crate soa_derive;
|
113 | 113 | //! # fn main() {
|
114 | 114 | //! # #[derive(Debug, PartialEq, StructOfArray)]
|
|
136 | 136 | //! fields from memory when iterating over the vector. In order to do so, one
|
137 | 137 | //! can manually pick the needed fields:
|
138 | 138 | //!
|
139 |
| -//! ```no_run |
| 139 | +//! ```ignore |
140 | 140 | //! # #[macro_use] extern crate soa_derive;
|
141 | 141 | //! # fn main() {
|
142 | 142 | //! # #[derive(Debug, PartialEq, StructOfArray)]
|
|
161 | 161 | //! In order to iterate over multiple fields at the same time, one can use the
|
162 | 162 | //! [soa_zip!](macro.soa_zip.html) macro.
|
163 | 163 | //!
|
164 |
| -//! ```no_run |
| 164 | +//! ```ignore |
165 | 165 | //! # #[macro_use] extern crate soa_derive;
|
166 | 166 | //! # fn main() {
|
167 | 167 | //! # #[derive(Debug, PartialEq, StructOfArray)]
|
|
182 | 182 | //! }
|
183 | 183 | //! # }
|
184 | 184 | //! ```
|
| 185 | +//! |
| 186 | +//! ## Nested Struct of Arrays |
| 187 | +//! |
| 188 | +//! In order to nest a struct of arrays inside another struct of arrays, one can use the `#[nested_soa]` attribute. |
| 189 | +//! |
| 190 | +//! For example, the following code |
| 191 | +//! |
| 192 | +//! ```ignore |
| 193 | +//! #[derive(StructOfArray)] |
| 194 | +//! pub struct Point { |
| 195 | +//! x: f32, |
| 196 | +//! y: f32, |
| 197 | +//! } |
| 198 | +//! #[derive(StructOfArray)] |
| 199 | +//! pub struct Particle { |
| 200 | +//! #[nested_soa] |
| 201 | +//! point: Point, |
| 202 | +//! mass: f32, |
| 203 | +//! } |
| 204 | +//! ``` |
| 205 | +//! |
| 206 | +//! will generate structs that looks like this: |
| 207 | +//! |
| 208 | +//! ```ignore |
| 209 | +//! pub struct PointVec { |
| 210 | +//! x: Vec<f32>, |
| 211 | +//! y: Vec<f32>, |
| 212 | +//! } |
| 213 | +//! pub struct ParticleVec { |
| 214 | +//! point: PointVec, // rather than Vec<Point> |
| 215 | +//! mass: Vec<f32> |
| 216 | +//! } |
| 217 | +//! ``` |
| 218 | +//! |
| 219 | +//! All helper structs will be also nested, for example `PointSlice` will be nested in `ParticleSlice`. |
185 | 220 |
|
186 | 221 | // The proc macro is implemented in soa_derive_internal, and re-exported by this
|
187 | 222 | // crate. This is because a single crate can not define both a proc macro and a
|
@@ -280,7 +315,7 @@ pub trait SoAIndexMut<T>: private_soa_indexes::Sealed {
|
280 | 315 | /// to the fields, which can be mutable references if the field name is prefixed
|
281 | 316 | /// with `mut`.
|
282 | 317 | ///
|
283 |
| -/// ``` |
| 318 | +/// ```ignore |
284 | 319 | /// # #[macro_use] extern crate soa_derive;
|
285 | 320 | /// # fn main() {
|
286 | 321 | /// #[derive(StructOfArray)]
|
@@ -311,7 +346,7 @@ pub trait SoAIndexMut<T>: private_soa_indexes::Sealed {
|
311 | 346 | /// iterator will yields elements until any of the fields or one external
|
312 | 347 | /// iterator returns None.
|
313 | 348 | ///
|
314 |
| -/// ``` |
| 349 | +/// ```ignore |
315 | 350 | /// # #[macro_use] extern crate soa_derive;
|
316 | 351 | /// # fn main() {
|
317 | 352 | /// # #[derive(StructOfArray)]
|
|
0 commit comments