Crates.io | disclose |
lib.rs | disclose |
version | 0.9.1 |
source | src |
created_at | 2023-08-21 15:37:01.83945 |
updated_at | 2023-08-21 15:37:01.83945 |
description | An attribute macro to set default visibilities on container elements. |
homepage | |
repository | |
max_upload_size | |
id | 950088 |
size | 6,864 |
disclose
is a macro crate designed to speed up creating modules that have lots of public components.
disclose
adds one feature to your package, the #[disclose]
attribute. Add this attribute to anything in a module with contents (mod, impl, struct, etc.) and it will effectively make everything in that scope pub
. It will not affect things that are already tagged with a visibility modifier, so if your struct contains one field you want to keep private and thirty you want to expose, you can tag that private field with pub(self)
and decorate the struct with #[disclose]
.
You can use disclose
with a scope as an argument, and it will apply that scope. So a mod marked with #[disclose(super)]
will treat every element without its own visibility tag as being pub(super)
. Thus,
#[disclose(self)]
pub struct Foo {
bar: usize;
pub baz: String;
pub(super) fud: Box<Foo>;
bro: i32;
}
will expand to
pub struct Foo {
pub(self) bar: usize;
pub baz: String;
pub(super) fud: Box<Foo>;
pub(self) bro: i32;
}
(Note that Foo
, baz
, and fud
are unchanged because they already had visibility annotations.)