Non-ugly ways to implement a 'static' class or namespace?

RTM riven at baryonides.ru
Fri Feb 17 10:03:59 UTC 2023


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.


More information about the Digitalmars-d-learn mailing list