summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml1
-rw-r--r--src/lib.rs25
2 files changed, 20 insertions, 6 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 4c06152..abf0eff 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,3 +15,4 @@ nul_in_strip = []
 
 [dependencies]
 libc = "0.2"
+impl_trait = "0.1"
diff --git a/src/lib.rs b/src/lib.rs
index ac8ef85..cae6363 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -183,6 +183,8 @@
  * -[ ] ???
  */
 
+#[macro_use]
+extern crate impl_trait;
 #[doc(hidden)]
 pub extern crate libc;
 
@@ -280,6 +282,11 @@ pub unsafe trait Plugin<'ph> {
     /// Called to deinitialize the plugin.
     ///
     /// This is always called immediately prior to Drop::drop.
+    ///
+    /// # A note about unwinding
+    ///
+    /// Panics in deinit will prevent the plugin from being correctly unloaded!
+    /// Be careful!
     fn deinit(self: Pin<&mut Self>, ph: &mut PluginHandle<'ph>) {
         let _ = ph;
     }
@@ -447,12 +454,18 @@ impl<'ph> Drop for PluginEntryHandle<'ph> {
     }
 }
 
-impl<'ph> Drop for Context<'ph> {
-    fn drop(&mut self) {
-        // check if we need to clean anything up
-        if self.ctx.strong_count() == 1 && self.ctx.weak_count() == 1 {
-            let strong = self.ctx.upgrade().unwrap();
-            self.contexts.borrow_mut().remove(&strong);
+impl_trait! {
+    impl<'ph> Context<'ph> {
+        impl trait UnwindSafe {}
+        impl trait RefUnwindSafe {}
+        impl trait Drop {
+            fn drop(&mut self) {
+                // check if we need to clean anything up
+                if self.ctx.strong_count() == 1 && self.ctx.weak_count() == 1 {
+                    let strong = self.ctx.upgrade().unwrap();
+                    self.contexts.borrow_mut().remove(&strong);
+                }
+            }
         }
     }
 }