Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bingmatv opened this issue Nov 2, 2024 · 1 comment
Open

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

bingmatv opened this issue Nov 2, 2024 · 1 comment

Comments

@bingmatv
Copy link

bingmatv commented Nov 2, 2024

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?

@SchrodingerZhu
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants