Hello,
i'm struggling with module visibility. I have a library with a module that i'd like to be accessible only to other programs defined in the same crate. I can only do it if i declare the module/fn as pub
. Is it possible to make this more constrained using pub(crate)
or pub( in::path)
somehow?
As an aside, the errors that i get bring me to the conclusion that files in src/bin
are not part of the crate. Is this correct? That makes me wonder if i Should just separate out the library from the executables into separate crates or workspaces.
A minimal example follows.
// src/lib.rs
// want to export module ffi to all programs in src/bin.
// pub(crate),pub( ?? ), pub(super) -- this leads to "too may leading `super keywords"
pub(crate) mod ffi {
pub(crate) fn ffi_fn() { println!("ffi_fn"); }
}
And i'd like to have a binary that can access the module ffi
// src/bin/prog.rs
use lib_vis::ffi;
fn main() {
ffi::ffi_fn();
}
thanks for any guidance.