My Rust project has a simple structure:
/src
/stuff
/mod.rs
/foo.rs
/stuff2
/mod.rs
/foo2.rs
Each mod.rs contains one line: pub mode foo;
or pub mod foo2;
In foo.rs, I have:
pub struct Foo {}
impl Foo {
fn private_method() {}
pub fn public_method() {}
pub fn visible_only_within_stuff_method() {}
}
How do I control the visibility of visible_only_within_stuff_method()
so all other code inside /stuff
can see it, but nothing outside it? I don’t want it to be available to anything inside /stuff2
.
What I’m looking for is the rough equivalent of package-private in Java.