Crates.io | fully_pub |
lib.rs | fully_pub |
version | 0.1.4 |
source | src |
created_at | 2023-04-08 22:23:56.471174 |
updated_at | 2023-04-09 12:26:53.755806 |
description | Macro that makes multiple items or fields public at once |
homepage | |
repository | https://github.com/lefebvreb/fully_pub |
max_upload_size | |
id | 833827 |
size | 23,280 |
This crate exposes a single attribute macro that can be
used to alleviate some of the verbosity of marking every field of
a Rust item as pub
,
by doing it automatically.
[dependencies]
fully_pub = "0.1"
use fully_pub::fully_pub;
#[fully_pub]
struct User {
name: String,
age: i32,
#[fully_pub(exclude)]
secret: String,
}
#[fully_pub]
impl User {
fn new(name: String, age: i32, secret: String) -> Self {
Self { name, age, secret }
}
fn happy_birthday(&mut self) {
self.age += 1;
}
#[fully_pub(exclude)]
fn get_secret(&mut self) -> &str {
&self.secret
}
}
This macro works on nearly everything in the Rust programming language, and can even be used on nested modules recursively, if needed.
See the documentation of the macro itself for more details.