How to Use the pub(crate) and pub(super) Visibility Modifiers

Use pub(crate) for crate-wide visibility and pub(super) for parent-module access in Rust.

Use pub(crate) to make an item visible only within the current crate, and pub(super) to make it visible to the immediate parent module.

mod parent {
    pub(crate) fn crate_wide() {}
    pub(super) fn parent_only() {}

    mod child {
        pub(super) fn child_to_parent() {}
    }
}