disclose

Crates.iodisclose
lib.rsdisclose
version0.9.1
sourcesrc
created_at2023-08-21 15:37:01.83945
updated_at2023-08-21 15:37:01.83945
descriptionAn attribute macro to set default visibilities on container elements.
homepage
repository
max_upload_size
id950088
size6,864
(alestane)

documentation

README

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.)

Commit count: 0

cargo fmt