[…]
We essentially would like to have a `#[sealed]` attribute that we can
put on a trait to avoid the `mod private { pub trait Sealed }` dance.
(so a trait that cannot be implemented outside of the module declaring
it)
---
Cheers,
Benno
This is not exactly what you said, but how about a declarative macro? e.g.:
macro_rules! sealed {
($($ty:ident),* $(,)?) => {
mod private {
pub trait Sealed {}
$(impl Sealed for super::$ty {})*
}
use private::Sealed;
};
}
sealed!(Unprepared, Prepared, Enabled)
Note that I am just brainstorming the general idea here, I did not test it yet.