mirror of
https://github.com/sam0x17/pub-fields.git
synced 2025-04-06 14:27:37 +03:00
docs
This commit is contained in:
parent
2054845649
commit
5b8b1366e3
2 changed files with 38 additions and 0 deletions
19
README.md
Normal file
19
README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
A simple attribute that makes all fields public on a struct.
|
||||
|
||||
Usage:
|
||||
```rust
|
||||
#[pub_fields]
|
||||
pub struct MyStruct {
|
||||
a: usize,
|
||||
b: usize,
|
||||
c: usize,
|
||||
}
|
||||
```
|
||||
=>
|
||||
```rust
|
||||
pub struct MyStruct {
|
||||
pub a: usize,
|
||||
pub b: usize,
|
||||
pub c: usize,
|
||||
}
|
||||
```
|
19
src/lib.rs
19
src/lib.rs
|
@ -2,6 +2,25 @@ use proc_macro::TokenStream;
|
|||
use quote::ToTokens;
|
||||
use syn::{parse::Nothing, parse_macro_input, parse_quote, ItemStruct};
|
||||
|
||||
/// A simple attribute that makes all fields public on a struct.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```rust
|
||||
/// #[pub_fields]
|
||||
/// pub struct MyStruct {
|
||||
/// a: usize,
|
||||
/// b: usize,
|
||||
/// c: usize,
|
||||
/// }
|
||||
/// ```
|
||||
/// =>
|
||||
/// ```rust
|
||||
/// pub struct MyStruct {
|
||||
/// pub a: usize,
|
||||
/// pub b: usize,
|
||||
/// pub c: usize,
|
||||
/// }
|
||||
/// ```
|
||||
#[proc_macro_attribute]
|
||||
pub fn pub_fields(attr: TokenStream, tokens: TokenStream) -> TokenStream {
|
||||
parse_macro_input!(attr as Nothing);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue