Funny, seems I have old news: Rust adopted D-like module visibility.

https://doc.rust-lang.org/reference/visibility-and-privacy.html

pub(in path), pub(crate), pub(super), and pub(self)

In addition to public and private, Rust allows users to declare an item as visible only within a given scope. The rules for pub restrictions are as follows:

pub(in path) makes an item visible within the provided path. path must be an ancestor module of the item whose visibility is being declared.
pub(crate) makes an item visible within the current crate.
pub(super) makes an item visible to the parent module. This is equivalent to pub(in super). pub(self) makes an item visible to the current module. This is equivalent to pub(in self) or not using pub at all.

Reply via email to