Last active
September 2, 2022 11:22
-
-
Save kiljacken/90655b7649177cb74a02f1470b13528c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1: Only my crate can implement *and* use it (plain visibilty) | |
pub(crate) trait AllocImpl {} | |
// 2: Only my module can implement the trait, others can use it | |
mod private { | |
pub trait Sealed {} | |
} | |
pub trait AllocImpl: private::Sealed {} | |
// 3: Other crates can implement but I have some private stuff only my module must do | |
pub trait AllocImpl {} | |
trait AllocImplExt: AllocImpl { | |
// the private stuff, implementation can only be in terms of things exposed in AllocImpl | |
} | |
impl<T: AllocImpl> AllocImplExt for T { | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment