make_public!() { /* proc-macro */ }Expand description
Recursively makes all top level items in a source public.
Accepts a block of Rust code and makes it so that:
- Functions become
pub fn - Structs become
pub struct, and all of their fields become public - Enums, types, traits (and trait aliases if the
unstablefeature is enabled), unions, statics, and constants becomepub - Modules become
pub modand everything underneath them recursively becomespub implblocks have all inner items made public (fn,const,type), unless implementing a traitimpl-associated types are madepubif theunstablefeature is enabled
ยงExample
pub_source::make_public! {
fn test() {}
struct Thing {
field1: u64,
field2: String,
}
impl Thing {
fn fancy(&self) {
let _ = self.field1;
}
}
}Expands to:
pub fn test() {}
pub struct Thing {
pub field1: u64,
pub field2: String,
}
impl Thing {
pub fn fancy(&self) {
let _ = self.field1;
}
}