Skip to content

Commit

Permalink
Add a clone_inner method to allow cloning of inner data (#3968)
Browse files Browse the repository at this point in the history
* Add a clone_inner method to allow cloning of inner data

* oops

* Address comment
  • Loading branch information
hansl authored Aug 27, 2024
1 parent 83ed291 commit c57f231
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/interop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@ impl<T: NativeObject> JsClass<T> {
}
}

impl<T: NativeObject + Clone> JsClass<T> {
/// 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<T> {
fn try_from_js_argument(
this: &'a JsValue,
Expand Down

0 comments on commit c57f231

Please sign in to comment.