Skip to content

Commit b9508d5

Browse files
hoshinolinajannau
authored andcommitted
rust: Add a Sealed trait
Some traits exposed by the kernel crate may not be intended to be implemented by downstream modules. Add a Sealed trait to allow avoiding this using the sealed trait pattern. Signed-off-by: Asahi Lina <lina@asahilina.net> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
1 parent 24fe5cc commit b9508d5

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

rust/kernel/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ pub use bindings;
9292
pub use macros;
9393
pub use uapi;
9494

95+
pub(crate) mod private {
96+
#[allow(unreachable_pub)]
97+
pub trait Sealed {}
98+
}
99+
95100
/// Prefix to appear before log messages printed from within the `kernel` crate.
96101
const __LOG_PREFIX: &[u8] = b"rust_kernel\0";
97102

0 commit comments

Comments
 (0)