浏览代码

feat(core): implement Clone for PluginHandle (#6644)

Lucas Fernandes Nogueira 2 年之前
父节点
当前提交
052c5822b5
共有 2 个文件被更改,包括 15 次插入1 次删除
  1. 5 0
      .changes/plugin-handle-clone.md
  2. 10 1
      core/tauri/src/plugin.rs

+ 5 - 0
.changes/plugin-handle-clone.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Implement `Clone` for `plugin::PluginHandle`.

+ 10 - 1
core/tauri/src/plugin.rs

@@ -70,13 +70,22 @@ type OnPageLoad<R> = dyn FnMut(Window<R>, PageLoadPayload) + Send;
 type OnDrop<R> = dyn FnOnce(AppHandle<R>) + Send;
 
 /// A handle to a plugin.
-#[derive(Clone)]
+#[derive(Debug)]
 #[allow(dead_code)]
 pub struct PluginHandle<R: Runtime> {
   name: &'static str,
   handle: AppHandle<R>,
 }
 
+impl<R: Runtime> Clone for PluginHandle<R> {
+  fn clone(&self) -> Self {
+    Self {
+      name: self.name,
+      handle: self.handle.clone(),
+    }
+  }
+}
+
 impl<R: Runtime> PluginHandle<R> {
   /// Returns the application handle.
   pub fn app(&self) -> &AppHandle<R> {