Text of rust.docs.kernel.org › pin_init › trait.PinnedDrop.html as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

PinnedDrop in pin_init - Rust

Skip to main content PinnedDrop pin_init Trait Pinned Drop Source pub unsafe trait PinnedDrop: HasPinData { // Required method fn drop (self: Pin <&mut Self>, only_call_from_drop: OnlyCallFromDrop); } Expand description Trait facilitating pinned destruction. Use pinned_drop to implement this trait safely: use core::pin::Pin; #[pin_data(PinnedDrop)] struct Foo { #[pin] mtx: CMutex<usize>, } #[pinned_drop] impl PinnedDrop for Foo { fn drop( self : Pin< &mut Self >) { println! ( "Foo is being dropped!" ); } } § Safety This trait must be implemented via the pinned_drop proc-macro attribute on the impl.

Required Methods § Source fn drop (self: Pin <&mut Self>, only_call_from_drop: OnlyCallFromDrop) Executes the pinned destructor of this type. While this function is marked safe, it is actually unsafe to call it manually. For this reason it takes an additional parameter. This type can only be constructed by unsafe code and thus prevents this function from being called where it should not. This extra parameter will be generated by the #[pinned_drop] proc-macro attribute automatically.

Dyn Compatibility § This trait is not dyn compatible . In older versions of Rust, dyn compatibility was called "object safety". Implementors §