1 unstable release
0.9.1 | Aug 21, 2023 |
---|
#24 in #visibility
Used in lemurs-8080
7KB
114 lines
disclose
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.)
Dependencies
~1.5MB
~36K SLoC