Skip to content

Commit 881c491

Browse files
committed
doc: mention lumol-org#44 about new feature
1 parent 73e0f24 commit 881c491

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,36 @@ If you want to add attribute to a specific generated struct(such as
5959
attribute `#[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]` to the
6060
struct declaration.
6161

62+
`soa_attr` could also be added to specific generated struct's field.
63+
64+
For example:
65+
6266
```rust
6367
#[derive(Debug, PartialEq, StructOfArray)]
6468
#[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]
6569
pub struct Cheese {
70+
#[soa_attr(Vec, deprecated)]
6671
pub smell: f64,
6772
pub color: (f64, f64, f64),
6873
pub with_mushrooms: bool,
6974
pub name: String,
7075
}
7176
```
7277

78+
will generate the struct like:
79+
80+
```rust
81+
#[cfg_attr(test, derive(PartialEq))]
82+
pub struct CheeseVec {
83+
#[deprecated]
84+
pub smell: Vec<f64>,
85+
pub color: Vec<(f64, f64, f64)>,
86+
pub with_mushrooms: Vec<bool>,
87+
pub name: Vec<String>,
88+
}
89+
```
90+
91+
7392
Mappings for first argument of ``soa_attr`` to the generated struct for ``Cheese``:
7493
* `Vec` => `CheeseVec`
7594
* `Slice` => `CheeseSlice`
@@ -79,6 +98,9 @@ Mappings for first argument of ``soa_attr`` to the generated struct for ``Cheese
7998
* `Ptr` => `CheesePtr`
8099
* `PtrMut` => `CheesePtrMut`
81100

101+
102+
To be mentioned, there is an [issue](https://github.com/lumol-org/soa-derive/issues/44) related to `#[soa_attr(Vec, serde(skip))]` on field.
103+
82104
## Usage and API
83105

84106
All the generated code have some generated documentation with it, so you

src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,17 @@
5757
//! attribute `#[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]` to the
5858
//! struct declaration.
5959
//!
60+
//! `soa_attr` could also be added to specific generated struct's field.
61+
//!
62+
//! For example:
63+
//!
6064
//! ```
6165
//! # #[macro_use] extern crate soa_derive;
6266
//! # fn main() {
6367
//! #[derive(Debug, PartialEq, StructOfArray)]
6468
//! #[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]
6569
//! pub struct Cheese {
70+
//! #[soa_attr(Vec, deprecated)]
6671
//! pub smell: f64,
6772
//! pub color: (f64, f64, f64),
6873
//! pub with_mushrooms: bool,
@@ -71,6 +76,19 @@
7176
//! # }
7277
//! ```
7378
//!
79+
//! will generate the struct like:
80+
//!
81+
//! ```rust
82+
//! #[cfg_attr(test, derive(PartialEq))]
83+
//! pub struct CheeseVec {
84+
//! #[deprecated]
85+
//! pub smell: Vec<f64>,
86+
//! pub color: Vec<(f64, f64, f64)>,
87+
//! pub with_mushrooms: Vec<bool>,
88+
//! pub name: Vec<String>,
89+
//! }
90+
//! ```
91+
//!
7492
//! Mappings for first argument of ``soa_attr`` to the generated struct for ``Cheese``:
7593
//! * `Vec` => `CheeseVec`
7694
//! * `Slice` => `CheeseSlice`
@@ -80,6 +98,9 @@
8098
//! * `Ptr` => `CheesePtr`
8199
//! * `PtrMut` => `CheesePtrMut`
82100
//!
101+
//!
102+
//! To be mentioned, there is an [issue](https://github.com/lumol-org/soa-derive/issues/44) related to `#[soa_attr(Vec, serde(skip))]` on field.
103+
//!
83104
//! # Usage and API
84105
//!
85106
//! All the generated code have some generated documentation with it, so you

0 commit comments

Comments
 (0)