Visibility rule issues
⚓ Rust 📅 2026-01-27 👤 surdeus 👁️ 1I have a program that has three source files:
main.rslib.rstemplate.rs(a module declared publicly inlib.rs
Currently, all items needed in main.rs are declared as public in template.rs. I don't want these items to be visible to external crates, though, as they are no use to callers who aren't me. I tried marking the items with pub(crate) but that caused Cargo to complain that the items are private and cannot be called in main.rs. Surely, though, main.rs and template.rs are in the same crate? I don't want to faff around with creating new modules or anything, but is there a way to make items declared in mod template visible to main.rs, while not being visible to callers using my crate?
Thanks!
2 posts - 2 participants
🏷️ Rust_feed