File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,22 @@ pub struct Cheese {
54
54
}
55
55
```
56
56
57
+ If you want to add attribute to a specific generated struct(such as
58
+ ` #[cfg_attr(test, derive(PartialEq))] ` on ` CheeseVec ` ), you can add an
59
+ attribute ` #[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))] ` to the
60
+ struct declaration.
61
+
62
+ ``` rust
63
+ #[derive(Debug , PartialEq , StructOfArray )]
64
+ #[soa_attr(Vec , cfg_attr(test, derive(PartialEq )))]
65
+ pub struct Cheese {
66
+ pub smell : f64 ,
67
+ pub color : (f64 , f64 , f64 ),
68
+ pub with_mushrooms : bool ,
69
+ pub name : String ,
70
+ }
71
+ ```
72
+
57
73
## Usage and API
58
74
59
75
All the generated code have some generated documentation with it, so you
Original file line number Diff line number Diff line change 51
51
//! }
52
52
//! # }
53
53
//! ```
54
+ //!
55
+ //! If you want to add attribute to a specific generated struct(such as
56
+ //! `#[cfg_attr(test, derive(PartialEq))]` on `CheeseVec`), you can add an
57
+ //! attribute `#[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]` to the
58
+ //! struct declaration.
59
+ //!
60
+ //! ```
61
+ //! # #[macro_use] extern crate soa_derive;
62
+ //! # fn main() {
63
+ //! #[derive(Debug, PartialEq, StructOfArray)]
64
+ //! #[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]
65
+ //! pub struct Cheese {
66
+ //! pub smell: f64,
67
+ //! pub color: (f64, f64, f64),
68
+ //! pub with_mushrooms: bool,
69
+ //! pub name: String,
70
+ //! }
71
+ //! # }
72
+ //! ```
73
+ //!
74
+ //! Possible options for first argument of ``soa_attr`` attribute: `Vec`, `Slice`,
75
+ //! `Ref` and `Ptr`.
54
76
//!
55
77
//! # Usage and API
56
78
//!
You can’t perform that action at this time.
0 commit comments