Allow to control visibility
tyranron opened this issue · 3 comments
tyranron commented
While using pub(crate) mod
allows to overcome nesting for impls, it also makes using #[sealed]
pointless in bounds of a single crate: imagine usage in application crate, where the trait is declared in some module, not other crate.
It would be nice to control the visibility via attribute argument:
#[sealed]
pub trait T {}
// expands to
mod __seal_t {}
#[sealed(pub(crate))]
pub trait T {}
// expands to
pub(crate) mod __seal_t {}
// And even follow an arbitrary visiblity:
// https://doc.rust-lang.org/reference/visibility-and-privacy.html
#[sealed(pub(in crate::very::long::path))]
pub trait T {}
// expands to
pub(in crate::very::long::path) mod __seal_t {}
So, for the nesting case (which is quite rare, AFAIK), an user should specify the visibility explicitly, while for the usage in non-library crate, the sealing will work well out-of-the-box.
tyranron commented
ping @jmg-duarte
jmg-duarte commented
I am sorry @tyranron, I've been working on another thing. I agree with the use case.
Are you interested in contributing with a PR?
tyranron commented
@jmg-duarte yup! Will do in a while.