3 ms·
> A `pub` symbol is accessible outside the current crate; This is not universally true; it's more that pub makes it accessible to the enclosing scope. Wrappin
by steveklabnik 2y ago
> A `pub` symbol is accessible outside the current crate;
This is not universally true; it's more that pub makes it accessible to the enclosing scope. Wrapping in an extra "mod" so that this works in one file:
mod foo {
mod bar {
pub fn baz() {
}
}
pub fn foo() {
bar::baz();
}
}
fn main() {
// this is okay, because foo can call baz
foo::foo();
// this is not okay, because bar is private, and so even though baz is marked pub, its parent module isn't
foo::bar::baz();
}
- Twisol 2y agoThanks for the correction! TIL :)