Skip to content

Commit

Permalink
Implement Copy and Clone for Handle<T> where T: !Copy
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Morenz <greg-morenz@droid.cafe>
  • Loading branch information
gmorenz committed Mar 10, 2025
1 parent 2c59822 commit 8850c4f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mozjs/src/gc/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,18 @@ impl<'a, const N: usize> From<&RootedGuard<'a, ValueArray<N>>> for JS::HandleVal
}
}

#[derive(Clone, Copy)]
pub struct Handle<'a, T: 'a> {
pub(crate) ptr: &'a T,
}

impl<T> Clone for Handle<'_, T> {
fn clone(&self) -> Self {
*self
}
}

impl<T> Copy for Handle<'_, T> {}

#[derive(Copy, Clone)]
pub struct MutableHandle<'a, T: 'a> {
pub(crate) ptr: *mut T,
Expand Down

0 comments on commit 8850c4f

Please sign in to comment.