#struct #proc-macro-attribute

macro public

A attribute macro used to mark struct/union and its fields as public

13 releases

0.2.2 Aug 20, 2021
0.2.1 Aug 20, 2021
0.2.0 Jun 28, 2021
0.1.9 Jun 9, 2021
0.1.0 Sep 22, 2020

#12 in #proc-macro-attribute

Download history 8/week @ 2023-10-14 9/week @ 2023-10-21 35/week @ 2023-10-28 27/week @ 2023-11-04 6/week @ 2023-11-11 7/week @ 2023-11-18 33/week @ 2023-11-25 43/week @ 2023-12-02 4/week @ 2023-12-09 18/week @ 2023-12-16 30/week @ 2023-12-23 4/week @ 2023-12-30 4/week @ 2024-01-06 6/week @ 2024-01-13 16/week @ 2024-01-20 28/week @ 2024-01-27

55 downloads per month
Used in extension-fn

GPL-3.0 license

14KB
69 lines

A Rust attribute macro used to mark struct/union and its fields as public

How to use

add the dependency to your Cargo.toml

[dependencies]
public = { git = "https://github.com/yuchunzhou/public", branch = "main" }

then, mark the struct with public attribute macro

#[macro_use]
extern crate public;

#[public]
#[derive(Debug, Default)]
struct Foo {
    a: i8,
    b: char,
    c: String,
}

the struct Foo and its fields will be visible within the current crate(default scope), of course, you can pass other scope arguments to the public attribute macro, like the usage of pub keyword in Rust.

No runtime deps