From c57f2310bff126b20aed146d24dae98018494076 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Tue, 27 Aug 2024 15:50:39 -0700 Subject: [PATCH] Add a clone_inner method to allow cloning of inner data (#3968) * Add a clone_inner method to allow cloning of inner data * oops * Address comment --- core/interop/src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/interop/src/lib.rs b/core/interop/src/lib.rs index 9196a27602..2813e9d046 100644 --- a/core/interop/src/lib.rs +++ b/core/interop/src/lib.rs @@ -390,6 +390,18 @@ impl JsClass { } } +impl JsClass { + /// Clones the inner class instance. + /// + /// # Panics + /// + /// Panics if the inner object is currently borrowed mutably. + #[must_use] + pub fn clone_inner(&self) -> T { + self.inner.borrow().data().clone() + } +} + impl<'a, T: NativeObject + 'static> TryFromJsArgument<'a> for JsClass { fn try_from_js_argument( this: &'a JsValue,