Skip to content

Commit bc29d51

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 cb6f614 commit bc29d51

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
@@ -93,6 +93,11 @@ pub use bindings;
9393
pub use macros;
9494
pub use uapi;
9595

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

0 commit comments

Comments
 (0)