Skip to content

Commit 8b7dadc

Browse files
committed
Improved PinnedDrop docs
1 parent c1ea0c7 commit 8b7dadc

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

rust/kernel/init.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,29 @@ where
643643

644644
/// Trait facilitating pinned destruction.
645645
///
646-
/// Use [`pinned_drop`] to implement this trait safely.
646+
/// Use [`pinned_drop`] to implement this trait safely:
647+
/// ```rust
648+
/// # use kernel::sync::Mutex;
649+
/// use kernel::macros::pinned_drop;
650+
/// #[pin_project]
651+
/// struct Foo {
652+
/// #[pin]
653+
/// mtx: Mutex<usize>,
654+
/// }
655+
///
656+
/// #[pinned_drop]
657+
/// impl PinnedDrop for Foo {
658+
/// fn drop(self: Pin<&mut Self>) {
659+
/// pr_info!("Foo is being dropped!");
660+
/// }
661+
/// }
662+
/// ```
663+
///
664+
/// # Safety
665+
///
666+
/// This trait must be implemented with [`pinned_drop`].
667+
///
668+
/// [`pinned_drop`]: kernel::macros::pinned_drop
647669
pub unsafe trait PinnedDrop {
648670
/// # Safety
649671
///

0 commit comments

Comments
 (0)