snmalloc icon indicating copy to clipboard operation
snmalloc copied to clipboard

Does it need "pub" keyword to access outside a module?

Open bingmatv opened this issue 1 year ago • 1 comments

Since it provides a Rust wrapper snmalloc-rs, the document suggests

#[global_allocator]
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;

for a Rust program. If a Rust project has multiple modules, should it add a "pub" keyword before "static" to share it for all modules?

bingmatv avatar Nov 02 '24 13:11 bingmatv

Please refer to https://doc.rust-lang.org/std/alloc/index.html to see the usage of global allocators. The declaration is to make snmalloc replace all allocation hooks. Users typically does not use the allocation functions of such global objects directly.

SchrodingerZhu avatar Nov 02 '24 14:11 SchrodingerZhu