#struct #proc-macro-attributes

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

#47 in #proc-macro-attributes

Download history 7/week @ 2024-03-11 15/week @ 2024-04-01 23/week @ 2024-04-08 29/week @ 2024-04-15 61/week @ 2024-04-22 10/week @ 2024-04-29 15/week @ 2024-05-06 59/week @ 2024-05-13 26/week @ 2024-05-20 4/week @ 2024-05-27 114/week @ 2024-06-03 22/week @ 2024-06-10 15/week @ 2024-06-24

151 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